<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Kavoir &#187; jQuery Tips &amp; FAQ</title>
	<atom:link href="http://www.kavoir.com/category/programming/jquery-tips-faq/feed" rel="self" type="application/rss+xml" />
	<link>http://www.kavoir.com</link>
	<description>Just another dumbass webmaster, goofing around...</description>
	<lastBuildDate>Thu, 09 Feb 2012 01:59:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to define multiple CSS rules / properties in jQuery?</title>
		<link>http://www.kavoir.com/2010/03/how-to-define-multiple-css-rules-properties-in-jquery.html</link>
		<comments>http://www.kavoir.com/2010/03/how-to-define-multiple-css-rules-properties-in-jquery.html#comments</comments>
		<pubDate>Wed, 03 Mar 2010 14:21:36 +0000</pubDate>
		<dc:creator>Yang Yang</dc:creator>
				<category><![CDATA[JavaScript Tips & Tutorials]]></category>
		<category><![CDATA[jQuery Tips & FAQ]]></category>

		<guid isPermaLink="false">http://www.kavoir.com/2010/03/how-to-define-multiple-css-rules-properties-in-jquery.html</guid>
		<description><![CDATA[The simplest way to define a CSS rule in jQuery might be: $(&#34;.sth&#34;).css(&#34;color&#34;, &#34;#f00&#34;); To define more than one CSS rule in a single jQuery line: $(&#34;.sth&#34;).css(&#34;color&#34;, &#34;#f00&#34;).css(&#34;font-style&#34;, &#34;italic&#34;).css(&#34;text-decoration&#34;, &#34;underline&#34;); Which simply doesn&#8217;t look that good, especially if you intend to add more. A better way to specify multiple CSS rules or properties with jQuery [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>The simplest way to define a CSS rule in jQuery might be:</p>

<pre><code>$(&quot;.sth&quot;).<strong>css</strong>(&quot;color&quot;, &quot;#f00&quot;);</code></pre>
<p>To define more than one CSS rule in a single jQuery line:</p>
<pre><code>$(&quot;.sth&quot;).<strong>css</strong>(&quot;color&quot;, &quot;#f00&quot;).<strong>css</strong>(&quot;font-style&quot;, &quot;italic&quot;).<strong>css</strong>(&quot;text-decoration&quot;, &quot;underline&quot;);</code></pre>
<p>Which simply doesn&#8217;t look that good, especially if you intend to add more. A better way to specify multiple CSS rules or properties with jQuery is by a JSON object:</p>
<pre><code>$(&quot;.sth&quot;).css( <strong>{'color' : '#f00', 'font-style' : 'italic', 'text-decoration' : 'underline'}</strong> );</code></pre>
<p>However, it is recommended that you use .<strong>addClass</strong>() instead of .<strong>css</strong>() to separate the JavaScript logics and CSS styles for maintainability.</p>
<h3>Related Posts:</h3>
<ul class="similar-posts">
<li><a href="http://www.kavoir.com/2009/06/html-change-text-and-font-colors.html" rel="bookmark" title="June 16, 2009">HTML: Change Text and Font Colors</a></li>
<li><a href="http://www.kavoir.com/2009/08/how-to-create-blinking-text-in-html.html" rel="bookmark" title="August 4, 2009">How to Create Blinking Text in HTML</a></li>
<li><a href="http://www.kavoir.com/2009/04/php-gd-library-drawing-functions-reference.html" rel="bookmark" title="April 22, 2009">PHP: GD Library Drawing Functions Reference</a></li>
<li><a href="http://www.kavoir.com/2012/01/customize-wordpress-post-editor-css-styles.html" rel="bookmark" title="January 19, 2012">Customize WordPress Post Editor CSS Styles</a></li>
<li><a href="http://www.kavoir.com/2009/03/styling-an-alphabet-of-26-letters-in-html-and-css.html" rel="bookmark" title="March 5, 2009">Styling an Alphabet of 26 Letters in HTML and CSS</a></li>
</ul>
<p><!-- Similar Posts took 3.319 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kavoir.com/2010/03/how-to-define-multiple-css-rules-properties-in-jquery.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery: Protecting or hiding variables / functions in a specific local scope</title>
		<link>http://www.kavoir.com/2009/04/jquery-protecting-or-hiding-variables-functions-in-a-specific-local-scope.html</link>
		<comments>http://www.kavoir.com/2009/04/jquery-protecting-or-hiding-variables-functions-in-a-specific-local-scope.html#comments</comments>
		<pubDate>Fri, 17 Apr 2009 03:00:35 +0000</pubDate>
		<dc:creator>Yang Yang</dc:creator>
				<category><![CDATA[JavaScript Tips & Tutorials]]></category>
		<category><![CDATA[jQuery Tips & FAQ]]></category>

		<guid isPermaLink="false">http://www.kavoir.com/2009/04/jquery-protecting-or-hiding-variables-functions-in-a-specific-local-scope.html</guid>
		<description><![CDATA[As everyone who’s well trained in software engineering would agree, that one of the principle of writing predictable code is to separate and hide something within only the scope that it’s needed. Controlled access to and from the outside world brings predictability and accountability of your code thus better debugging. In jQuery, you need constantly [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>As everyone who’s well trained in software engineering would agree, that one of the principle of writing predictable code is to separate and hide something within only the scope that it’s needed. Controlled access to and from the outside world brings predictability and accountability of your code thus better debugging.</p>

<p>In jQuery, you need constantly extending the native features by writing extra plugins and adding new functions:</p>
<pre><code>var newMethods = {
  check       : function() { ... },
  uncheck     : function() { ... },
  toggleCheck : function() { ... }
};
jQuery.each(newMethods, function(i) {
  jQuery.fn[i] = this;
});</code></pre>
<p>Without proper fencing, the variable containing 3 functions <strong>newMethods</strong> is everything but protected from the global scope (outside world), increaseing the complexity of the code and difficulty in debugging. To solve this problem, you will want to embrace the code in <strong>an anonymous function</strong>.</p>
<pre><code><strong>(function() {</strong>
  var newMethods = {
    check       : function() { ... },
    uncheck     : function() { ... },
    toggleCheck : function() { ... }
  };
  jQuery.each(newMethods, function(i) {
    jQuery.fn[i] = this;
  });
<strong>})();</strong></code></pre>
<h3>Related Posts:</h3>
<ul class="similar-posts">
<li><a href="http://www.kavoir.com/2009/04/jquery-check-uncheck-form-checkbox-and-radio.html" rel="bookmark" title="April 16, 2009">jQuery: Check / uncheck form checkbox and radio</a></li>
<li><a href="http://www.kavoir.com/2010/09/regular-expression-for-natural-numbers-or-positive-integers-1-2-3-11-12.html" rel="bookmark" title="September 29, 2010">Regular Expressions for Natural Numbers or Positive Integers (1, 2, 3, &hellip;), Negative Integers and Non-negative Integers</a></li>
<li><a href="http://www.kavoir.com/2009/03/incisive-software-engineering-programming-quotes-and-sayings.html" rel="bookmark" title="March 10, 2009">Incisive Software Engineering &amp; Programming Quotes and Sayings</a></li>
<li><a href="http://www.kavoir.com/2009/04/jquery-how-to-check-if-an-element-has-a-particular-class.html" rel="bookmark" title="April 16, 2009">jQuery: How to check if an element has a particular class</a></li>
<li><a href="http://www.kavoir.com/2010/03/how-to-define-multiple-css-rules-properties-in-jquery.html" rel="bookmark" title="March 3, 2010">How to define multiple CSS rules / properties in jQuery?</a></li>
</ul>
<p><!-- Similar Posts took 3.408 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kavoir.com/2009/04/jquery-protecting-or-hiding-variables-functions-in-a-specific-local-scope.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery: Get the text and value of the selected option of HTML select element</title>
		<link>http://www.kavoir.com/2009/04/jquery-get-the-text-and-value-of-the-selected-option-of-html-select-element.html</link>
		<comments>http://www.kavoir.com/2009/04/jquery-get-the-text-and-value-of-the-selected-option-of-html-select-element.html#comments</comments>
		<pubDate>Thu, 16 Apr 2009 15:30:04 +0000</pubDate>
		<dc:creator>Yang Yang</dc:creator>
				<category><![CDATA[JavaScript Tips & Tutorials]]></category>
		<category><![CDATA[jQuery Tips & FAQ]]></category>

		<guid isPermaLink="false">http://www.kavoir.com/2009/04/jquery-get-the-text-and-value-of-the-selected-option-of-html-select-element.html</guid>
		<description><![CDATA[For instance, there’s a HTML select element identified by the ID #title, and after the user has selected one of the options, you want to get the text and value of the selected option. &#60;select id=&#34;title&#34;&#62; &#60;option value=&#34;1&#34;&#62;Mr&#60;/option&#62; &#60;option value=&#34;2&#34;&#62;Mrs&#60;/option&#62; &#60;option value=&#34;3&#34;&#62;Miss&#60;/option&#62; &#60;/select&#62; Now that the user has selected the 2nd option: Mrs. To get [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>For instance, there’s a HTML select element identified by the ID #title, and after the user has selected one of the options, you want to get the text and value of the selected option.</p>

<pre><code>&lt;select id=&quot;title&quot;&gt;
  &lt;option value=&quot;1&quot;&gt;Mr&lt;/option&gt;
  &lt;option value=&quot;2&quot;&gt;Mrs&lt;/option&gt;
  &lt;option value=&quot;3&quot;&gt;Miss&lt;/option&gt;
&lt;/select&gt;</code></pre>
<p>Now that the user has selected the 2nd option: Mrs. To get the value (in this case, ‘2’):</p>
<p><code>$(&quot;select#title&quot;).<strong>val</strong>();</code> </p>
<p>Which is also the common function to return the value of all other form controls.</p>
<p>To get the text of the selected option (in this case, ‘Mrs’):</p>
<p><code>$(&quot;#title option<strong>:selected</strong>&quot;).<strong>text</strong>();</code><br />
<h3>Related Posts:</h3>
<ul class="similar-posts">
<li><a href="http://www.kavoir.com/2009/02/php-drop-down-list.html" rel="bookmark" title="February 8, 2009">PHP: Drop Down List with Select</a></li>
<li><a href="http://www.kavoir.com/2011/12/javascript-load-image-based-on-select-option.html" rel="bookmark" title="December 25, 2011">JavaScript: Load Image based on Select Option (Dropdown)</a></li>
<li><a href="http://www.kavoir.com/2009/08/html-tags-design-for-template-theme-creation.html" rel="bookmark" title="August 27, 2009">HTML Tags Design for Template / Theme Creation</a></li>
<li><a href="http://www.kavoir.com/2010/11/mysql-export-table-to-csv-text-files-for-excel.html" rel="bookmark" title="November 18, 2010">MySQL: Export Table to CSV Text Files for Excel</a></li>
<li><a href="http://www.kavoir.com/2010/02/php-allow-specific-html-tags-in-text-input-controls-of-html-forms-textarea-input-typetext.html" rel="bookmark" title="February 15, 2010">PHP: Allow Specific HTML Tags in Text Input Controls of HTML Forms, &lt;textarea&gt;, &lt;input type=&rdquo;text&rdquo; /&gt;</a></li>
</ul>
<p><!-- Similar Posts took 3.894 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kavoir.com/2009/04/jquery-get-the-text-and-value-of-the-selected-option-of-html-select-element.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>jQuery: Check / uncheck form checkbox and radio</title>
		<link>http://www.kavoir.com/2009/04/jquery-check-uncheck-form-checkbox-and-radio.html</link>
		<comments>http://www.kavoir.com/2009/04/jquery-check-uncheck-form-checkbox-and-radio.html#comments</comments>
		<pubDate>Thu, 16 Apr 2009 15:18:06 +0000</pubDate>
		<dc:creator>Yang Yang</dc:creator>
				<category><![CDATA[JavaScript Tips & Tutorials]]></category>
		<category><![CDATA[jQuery Tips & FAQ]]></category>

		<guid isPermaLink="false">http://www.kavoir.com/2009/04/jquery-check-uncheck-form-checkbox-and-radio.html</guid>
		<description><![CDATA[Using both attr() and removeAttr() functions, it’s actually the same as enabling and disabling form controls with jQuery. $(&#34;#option&#34;).attr(&#34;checked&#34;, &#34;checked&#34;); // make checkbox or radio checked $(&#34;#option&#34;).removeAttr(&#34;checked&#34;); // uncheck the checkbox or radio Related Posts: How to disable or enable a form element with jQuery? CSS: How to align HTML input checkbox and radio with [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Using both attr() and removeAttr() functions, it’s actually the same as <a href="http://www.kavoir.com/2009/04/how-to-disable-or-enable-a-form-element-with-jquery.html">enabling and disabling form controls with jQuery</a>.</p>

<p> <code>$(&quot;#option&quot;).<strong>attr</strong>(&quot;checked&quot;, &quot;checked&quot;); // make checkbox or radio checked     <br />$(&quot;#option&quot;).<strong>removeAttr</strong>(&quot;checked&quot;); // uncheck the checkbox or radio</code><br />
<h3>Related Posts:</h3>
<ul class="similar-posts">
<li><a href="http://www.kavoir.com/2009/04/how-to-disable-or-enable-a-form-element-with-jquery.html" rel="bookmark" title="April 16, 2009">How to disable or enable a form element with jQuery?</a></li>
<li><a href="http://www.kavoir.com/2009/08/css-how-to-align-html-input-checkbox-and-radio-with-text-in-the-same-line.html" rel="bookmark" title="August 29, 2009">CSS: How to align HTML input checkbox and radio with text on the same line?</a></li>
<li><a href="http://www.kavoir.com/2009/04/jquery-protecting-or-hiding-variables-functions-in-a-specific-local-scope.html" rel="bookmark" title="April 17, 2009">jQuery: Protecting or hiding variables / functions in a specific local scope</a></li>
<li><a href="http://www.kavoir.com/2009/01/php-checkbox-array-in-form-handling-multiple-checkbox-values-in-an-array.html" rel="bookmark" title="January 31, 2009">PHP: Checkbox Array in Form Handling &#8211; Multiple Checkbox Values in an Array</a></li>
<li><a href="http://www.kavoir.com/2009/04/jquery-get-the-text-and-value-of-the-selected-option-of-html-select-element.html" rel="bookmark" title="April 16, 2009">jQuery: Get the text and value of the selected option of HTML select element</a></li>
</ul>
<p><!-- Similar Posts took 3.821 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kavoir.com/2009/04/jquery-check-uncheck-form-checkbox-and-radio.html/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>jQuery: How to check if an element has a particular class</title>
		<link>http://www.kavoir.com/2009/04/jquery-how-to-check-if-an-element-has-a-particular-class.html</link>
		<comments>http://www.kavoir.com/2009/04/jquery-how-to-check-if-an-element-has-a-particular-class.html#comments</comments>
		<pubDate>Thu, 16 Apr 2009 15:08:08 +0000</pubDate>
		<dc:creator>Yang Yang</dc:creator>
				<category><![CDATA[JavaScript Tips & Tutorials]]></category>
		<category><![CDATA[jQuery Tips & FAQ]]></category>

		<guid isPermaLink="false">http://www.kavoir.com/2009/04/jquery-how-to-check-if-an-element-has-a-particular-class.html</guid>
		<description><![CDATA[To know whether a class exists on an element with jQuery, you need a simple test method: is(). For example, to test if an element #elm has the class ‘first’: if ($(#elm).is('.first')) { //#elm has the class } else { //#elm doesn't have the class } jQuery is() is the function that checks if any [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>To know whether a class exists on an element with jQuery, you need a simple test method: <strong>is()</strong>.</p>

<p>For example, to test if an element #elm has the class ‘first’:</p>
<pre><code>if ($(#elm).<strong>is</strong>('.first')) {
//#elm has the class
} else {
//#elm doesn't have the class
}</code></pre>
<p>jQuery is() is the function that checks if any of the returned DOM objects from the selector satisfies the criteria set in the argument.</p>
<h3>Related Posts:</h3>
<ul class="similar-posts">
<li><a href="http://www.kavoir.com/2009/04/jquery-how-to-test-or-check-whether-an-element-exists.html" rel="bookmark" title="April 16, 2009">jQuery: How to test or check whether an element exists</a></li>
<li><a href="http://www.kavoir.com/2009/04/jquery-selecting-elements-with-uncommon-special-characters-in-id-or-class-name.html" rel="bookmark" title="April 16, 2009">jQuery: Selecting elements with uncommon / special characters in ID or class name</a></li>
<li><a href="http://www.kavoir.com/2009/04/jquery-protecting-or-hiding-variables-functions-in-a-specific-local-scope.html" rel="bookmark" title="April 17, 2009">jQuery: Protecting or hiding variables / functions in a specific local scope</a></li>
<li><a href="http://www.kavoir.com/2009/01/php-file-upload-class.html" rel="bookmark" title="January 15, 2009">PHP: File Upload Script (HTML Form + PHP Handler Class)</a></li>
<li><a href="http://www.kavoir.com/2009/05/mysql-insert-if-doesnt-exist-otherwise-update-the-existing-row.html" rel="bookmark" title="May 2, 2009">MySQL: Insert if doesn&rsquo;t exist otherwise update the existing row</a></li>
</ul>
<p><!-- Similar Posts took 3.933 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kavoir.com/2009/04/jquery-how-to-check-if-an-element-has-a-particular-class.html/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>jQuery: How to test or check whether an element exists</title>
		<link>http://www.kavoir.com/2009/04/jquery-how-to-test-or-check-whether-an-element-exists.html</link>
		<comments>http://www.kavoir.com/2009/04/jquery-how-to-test-or-check-whether-an-element-exists.html#comments</comments>
		<pubDate>Thu, 16 Apr 2009 15:02:34 +0000</pubDate>
		<dc:creator>Yang Yang</dc:creator>
				<category><![CDATA[JavaScript Tips & Tutorials]]></category>
		<category><![CDATA[jQuery Tips & FAQ]]></category>

		<guid isPermaLink="false">http://www.kavoir.com/2009/04/jquery-how-to-test-or-check-whether-an-element-exists.html</guid>
		<description><![CDATA[.length property in JavaScript returns the length or number of elements inside an array or the string length. While jQuery selector mechanism $(“elm”) returns an array of DOM objects (such as elements), you can also get the number of the length of the returned objects array by: $(&#34;#some&#34;).length To check the existence of the element, [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>.length property in JavaScript returns the length or number of elements inside an array or the string length. While jQuery selector mechanism $(“elm”) returns an array of DOM objects (such as elements), you can also get the number of the length of the returned objects array by:</p>

<p> <code>$(&quot;#some&quot;).length</code>
<p>To check the existence of the element, just check if the returned value of length is zero: </p>
<p> <code>if ($(&quot;#some&quot;).length) { //#some element exists }</code><br />
<h3>Related Posts:</h3>
<ul class="similar-posts">
<li><a href="http://www.kavoir.com/2009/01/php-array-length-function-to-get-length-of-arrays.html" rel="bookmark" title="January 9, 2009">PHP Array Length Function to Get Length of Arrays</a></li>
<li><a href="http://www.kavoir.com/2009/07/php-count-words-in-a-string.html" rel="bookmark" title="July 29, 2009">PHP: Count Words in a String</a></li>
<li><a href="http://www.kavoir.com/2009/04/jquery-how-to-check-if-an-element-has-a-particular-class.html" rel="bookmark" title="April 16, 2009">jQuery: How to check if an element has a particular class</a></li>
<li><a href="http://www.kavoir.com/2009/01/php-string-length-function-to-get-length-of-strings-in-php.html" rel="bookmark" title="January 10, 2009">PHP String Length function to Get Length of Strings in PHP</a></li>
<li><a href="http://www.kavoir.com/2009/06/javascript-split-and-divide-text-string-by-a-delimiter.html" rel="bookmark" title="June 16, 2009">JavaScript: Split and Divide Text String by A Delimiter</a></li>
</ul>
<p><!-- Similar Posts took 2.500 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kavoir.com/2009/04/jquery-how-to-test-or-check-whether-an-element-exists.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery: Selecting elements with uncommon / special characters in ID or class name</title>
		<link>http://www.kavoir.com/2009/04/jquery-selecting-elements-with-uncommon-special-characters-in-id-or-class-name.html</link>
		<comments>http://www.kavoir.com/2009/04/jquery-selecting-elements-with-uncommon-special-characters-in-id-or-class-name.html#comments</comments>
		<pubDate>Thu, 16 Apr 2009 14:55:09 +0000</pubDate>
		<dc:creator>Yang Yang</dc:creator>
				<category><![CDATA[JavaScript Tips & Tutorials]]></category>
		<category><![CDATA[jQuery Tips & FAQ]]></category>

		<guid isPermaLink="false">http://www.kavoir.com/2009/04/jquery-selecting-elements-with-uncommon-special-characters-in-id-or-class-name.html</guid>
		<description><![CDATA[HTML generated by some CMS or frameworks include elements with rather uncommon characters in ID or class names. For example, some may have special characters such as ‘.’ or ‘[..]’ in the ID or Class. To work around this, a selector in jQuery should be written this way: $("$some.id") // won't work for ID: some.id [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>HTML generated by some CMS or frameworks include elements with rather uncommon characters in ID or class names. For example, some may have special characters such as ‘.’ or ‘[..]’ in the ID or Class. To work around this, a selector in jQuery should be written this way:</p>

<pre><code>$("$some.id") // won't work for ID: some.id</code> <code>$("$some\\.id") // works for ID: some.id</code></pre>
<p>With brackets in ID:</p>
<pre><code>$("$some[id]") // won't work for ID: some[id]</code> <code>$("$some\\[id\\]") // works for ID: some[id]</code></pre>
<p>You get the idea. Just add double backslashes <strong>\\</strong> before any of the special characters.<br />
<h3>Related Posts:</h3>
<ul class="similar-posts">
<li><a href="http://www.kavoir.com/2009/04/jquery-how-to-check-if-an-element-has-a-particular-class.html" rel="bookmark" title="April 16, 2009">jQuery: How to check if an element has a particular class</a></li>
<li><a href="http://www.kavoir.com/2009/06/php-difference-between-htmlspecialchars-and-htmlentities-functions.html" rel="bookmark" title="June 2, 2009">PHP: Difference between htmlspecialchars() and htmlentities() Functions</a></li>
<li><a href="http://www.kavoir.com/2009/08/how-to-display-html-code-on-a-web-page.html" rel="bookmark" title="August 4, 2009">How to display HTML code on a web page?</a></li>
<li><a href="http://www.kavoir.com/2009/02/css-double-border.html" rel="bookmark" title="February 8, 2009">CSS: Double Border</a></li>
<li><a href="http://www.kavoir.com/2009/04/jquery-protecting-or-hiding-variables-functions-in-a-specific-local-scope.html" rel="bookmark" title="April 17, 2009">jQuery: Protecting or hiding variables / functions in a specific local scope</a></li>
</ul>
<p><!-- Similar Posts took 2.512 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kavoir.com/2009/04/jquery-selecting-elements-with-uncommon-special-characters-in-id-or-class-name.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to disable or enable a form element with jQuery?</title>
		<link>http://www.kavoir.com/2009/04/how-to-disable-or-enable-a-form-element-with-jquery.html</link>
		<comments>http://www.kavoir.com/2009/04/how-to-disable-or-enable-a-form-element-with-jquery.html#comments</comments>
		<pubDate>Thu, 16 Apr 2009 14:45:32 +0000</pubDate>
		<dc:creator>Yang Yang</dc:creator>
				<category><![CDATA[JavaScript Tips & Tutorials]]></category>
		<category><![CDATA[jQuery Tips & FAQ]]></category>

		<guid isPermaLink="false">http://www.kavoir.com/2009/04/how-to-disable-or-enable-a-form-element-with-jquery.html</guid>
		<description><![CDATA[You need 2 jQuery functions: attr and removeAttr. To disable a form element such as a text input or a button (with a made-up id: #elm): $(&#34;#elm&#34;).attr(&#34;disabled&#34;, &#34;disabled&#34;); To enable a disabled form element: $(&#34;#elm&#34;).removeAttr(&#34;disabled&#34;); Related Posts: jQuery: Check / uncheck form checkbox and radio CSS: Styling File Upload / Select Input Control &#60;input type=&#34;file&#34; [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>You need 2 jQuery functions: attr and removeAttr.</p>
<p>To disable a form element such as a text input or a button (with a made-up id: #elm):</p>

<p> <code>$(&quot;#elm&quot;).<strong>attr</strong>(&quot;disabled&quot;, &quot;disabled&quot;);</code>
<p>To enable a disabled form element: </p>
<p> <code>$(&quot;#elm&quot;).<strong>removeAttr</strong>(&quot;disabled&quot;);</code><br />
<h3>Related Posts:</h3>
<ul class="similar-posts">
<li><a href="http://www.kavoir.com/2009/04/jquery-check-uncheck-form-checkbox-and-radio.html" rel="bookmark" title="April 16, 2009">jQuery: Check / uncheck form checkbox and radio</a></li>
<li><a href="http://www.kavoir.com/2009/02/styling-file-upload-select-input-control-input-typefile.html" rel="bookmark" title="February 8, 2009">CSS: Styling File Upload / Select Input Control &lt;input type=&quot;file&quot; &hellip; /&gt;</a></li>
<li><a href="http://www.kavoir.com/2009/04/jquery-how-to-check-if-an-element-has-a-particular-class.html" rel="bookmark" title="April 16, 2009">jQuery: How to check if an element has a particular class</a></li>
<li><a href="http://www.kavoir.com/2010/07/javascript-how-to-set-focus-to-form-elements.html" rel="bookmark" title="July 22, 2010">JavaScript: How to set focus to form elements?</a></li>
<li><a href="http://www.kavoir.com/2009/04/jquery-protecting-or-hiding-variables-functions-in-a-specific-local-scope.html" rel="bookmark" title="April 17, 2009">jQuery: Protecting or hiding variables / functions in a specific local scope</a></li>
</ul>
<p><!-- Similar Posts took 3.814 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kavoir.com/2009/04/how-to-disable-or-enable-a-form-element-with-jquery.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

