<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: jQuery Tip : How to Select Radio/Checkbox Input On Click</title>
	<atom:link href="http://dev-tips.com/featured/jquery-tip-how-to-select-radiocheckbox-input-on-click/feed" rel="self" type="application/rss+xml" />
	<link>http://dev-tips.com/featured/jquery-tip-how-to-select-radiocheckbox-input-on-click</link>
	<description>Become a Better Developer, One Tip at a Time.</description>
	<lastBuildDate>Wed, 04 Aug 2010 15:39:50 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
	<item>
		<title>By: Ziad</title>
		<link>http://dev-tips.com/featured/jquery-tip-how-to-select-radiocheckbox-input-on-click#comment-1733</link>
		<dc:creator>Ziad</dc:creator>
		<pubDate>Wed, 31 Mar 2010 13:01:30 +0000</pubDate>
		<guid isPermaLink="false">http://dev-tips.com/?p=80#comment-1733</guid>
		<description>Great tip Barry, thanks!

I was trying to do it the other way around but ran into some problem. The code works but only on the last radio button set. Not sure why:

&lt;code&gt;
$(
	function radioHighlight(radioName, className) {
		radioNameSelector = &quot;input[name=&#039;&quot; + radioName + &quot;&#039;]&quot;;
		$(radioNameSelector).click(function() {
			$(radioNameSelector).parent().removeClass(className);
			$(radioNameSelector + &#039;:checked&#039;).parent().addClass(className);
		});
	}	

	radioHighlight(&#039;beneficiary&#039;, &#039;box_selected&#039;);
	radioHighlight(&#039;trans_type&#039;, &#039;box_selected&#039;);
);
&lt;/code&gt;

My HTML is like this:

&lt;code&gt;
 By Credit/Debit Card
 By PayPal
 By Bank Transfer
 By Cheque
&lt;/code&gt;

Thanks again
Ziad</description>
		<content:encoded><![CDATA[<p>Great tip Barry, thanks!</p>
<p>I was trying to do it the other way around but ran into some problem. The code works but only on the last radio button set. Not sure why:</p>
<p><code><br />
$(<br />
	function radioHighlight(radioName, className) {<br />
		radioNameSelector = "input[name='" + radioName + "']";<br />
		$(radioNameSelector).click(function() {<br />
			$(radioNameSelector).parent().removeClass(className);<br />
			$(radioNameSelector + ':checked').parent().addClass(className);<br />
		});<br />
	}	</p>
<p>	radioHighlight('beneficiary', 'box_selected');<br />
	radioHighlight('trans_type', 'box_selected');<br />
);<br />
</code></p>
<p>My HTML is like this:</p>
<p><code><br />
 By Credit/Debit Card<br />
 By PayPal<br />
 By Bank Transfer<br />
 By Cheque<br />
</code></p>
<p>Thanks again<br />
Ziad</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam</title>
		<link>http://dev-tips.com/featured/jquery-tip-how-to-select-radiocheckbox-input-on-click#comment-1709</link>
		<dc:creator>Adam</dc:creator>
		<pubDate>Tue, 09 Mar 2010 23:48:42 +0000</pubDate>
		<guid isPermaLink="false">http://dev-tips.com/?p=80#comment-1709</guid>
		<description>A problem:

Say you have two radio buttons (yes/no) and you want to trigger a $(&quot;#foo&quot;).show(); event from one of them, but not the other, such that if someone clicks the &#039;yes&#039; option, you get a div to appear, click &#039;no&#039; and nothing appears to happen.</description>
		<content:encoded><![CDATA[<p>A problem:</p>
<p>Say you have two radio buttons (yes/no) and you want to trigger a $(&#8220;#foo&#8221;).show(); event from one of them, but not the other, such that if someone clicks the &#8216;yes&#8217; option, you get a div to appear, click &#8216;no&#8217; and nothing appears to happen.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Barry Roodt</title>
		<link>http://dev-tips.com/featured/jquery-tip-how-to-select-radiocheckbox-input-on-click#comment-1231</link>
		<dc:creator>Barry Roodt</dc:creator>
		<pubDate>Sun, 20 Dec 2009 19:25:51 +0000</pubDate>
		<guid isPermaLink="false">http://dev-tips.com/?p=80#comment-1231</guid>
		<description>Hi Paul,

Aah ok i see now. .children() returns an array of elements. Well spotted, and thanks for the fix.</description>
		<content:encoded><![CDATA[<p>Hi Paul,</p>
<p>Aah ok i see now. .children() returns an array of elements. Well spotted, and thanks for the fix.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul</title>
		<link>http://dev-tips.com/featured/jquery-tip-how-to-select-radiocheckbox-input-on-click#comment-1221</link>
		<dc:creator>Paul</dc:creator>
		<pubDate>Sat, 19 Dec 2009 22:35:16 +0000</pubDate>
		<guid isPermaLink="false">http://dev-tips.com/?p=80#comment-1221</guid>
		<description>I was experiencing the &#039;too much recursion&#039; error in FF 3.5.6. It seems the click() gets evaluated on the &#039;li&#039; element rather than the included radio button.

Changing the third line to
&lt;code&gt;$(this).addClass(&#039;selected&#039;).children(&quot;input[@type=radio]&quot;)[0].click();&lt;/code&gt;
did the trick, at least in FF.

And thanks for your nice article, Barry!</description>
		<content:encoded><![CDATA[<p>I was experiencing the &#8216;too much recursion&#8217; error in FF 3.5.6. It seems the click() gets evaluated on the &#8216;li&#8217; element rather than the included radio button.</p>
<p>Changing the third line to<br />
<code>$(this).addClass('selected').children("input[@type=radio]")[0].click();</code><br />
did the trick, at least in FF.</p>
<p>And thanks for your nice article, Barry!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: indialike</title>
		<link>http://dev-tips.com/featured/jquery-tip-how-to-select-radiocheckbox-input-on-click#comment-1211</link>
		<dc:creator>indialike</dc:creator>
		<pubDate>Wed, 16 Dec 2009 08:11:54 +0000</pubDate>
		<guid isPermaLink="false">http://dev-tips.com/?p=80#comment-1211</guid>
		<description>Very nice and useful tutorials to web designers,
Thanks for posting.</description>
		<content:encoded><![CDATA[<p>Very nice and useful tutorials to web designers,<br />
Thanks for posting.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Barry Roodt</title>
		<link>http://dev-tips.com/featured/jquery-tip-how-to-select-radiocheckbox-input-on-click#comment-1109</link>
		<dc:creator>Barry Roodt</dc:creator>
		<pubDate>Fri, 27 Nov 2009 04:41:04 +0000</pubDate>
		<guid isPermaLink="false">http://dev-tips.com/?p=80#comment-1109</guid>
		<description>I&#039;m not sure that I&#039;m with you, there&#039;s no recursion there.

That piece of code is listening for a click on an LI element. The &quot;.children(&quot;input[type=radio]&quot;).click()&quot; bit is firing a click event on the radio input element directly, not the LI - so no recursion.

Am I missing something ? Do you have an example perhaps.. might make more sense to me then.

Thanks</description>
		<content:encoded><![CDATA[<p>I&#8217;m not sure that I&#8217;m with you, there&#8217;s no recursion there.</p>
<p>That piece of code is listening for a click on an LI element. The &#8220;.children(&#8220;input[type=radio]&#8220;).click()&#8221; bit is firing a click event on the radio input element directly, not the LI &#8211; so no recursion.</p>
<p>Am I missing something ? Do you have an example perhaps.. might make more sense to me then.</p>
<p>Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Yue</title>
		<link>http://dev-tips.com/featured/jquery-tip-how-to-select-radiocheckbox-input-on-click#comment-1108</link>
		<dc:creator>Yue</dc:creator>
		<pubDate>Fri, 27 Nov 2009 00:04:26 +0000</pubDate>
		<guid isPermaLink="false">http://dev-tips.com/?p=80#comment-1108</guid>
		<description>I have to say
&lt;code&gt;
$(&#039;li&#039;).click( function(){
		$(&#039;li.selected&#039;).removeClass(&#039;selected&#039;);
		$(this).addClass(&#039;selected&#039;).children(&quot;input[@type=radio]&quot;).click();
	});
&lt;/code&gt;
this code can trigger out of memory error in IE8 because of too many recursive event</description>
		<content:encoded><![CDATA[<p>I have to say<br />
<code><br />
$('li').click( function(){<br />
		$('li.selected').removeClass('selected');<br />
		$(this).addClass('selected').children("input[@type=radio]").click();<br />
	});<br />
</code><br />
this code can trigger out of memory error in IE8 because of too many recursive event</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kiran Kumar</title>
		<link>http://dev-tips.com/featured/jquery-tip-how-to-select-radiocheckbox-input-on-click#comment-860</link>
		<dc:creator>Kiran Kumar</dc:creator>
		<pubDate>Tue, 28 Jul 2009 16:27:12 +0000</pubDate>
		<guid isPermaLink="false">http://dev-tips.com/?p=80#comment-860</guid>
		<description>Hi Barry,
thank you for your post, i was just looking for this type of code for radio and checkboxes.

you have given code for radio button. i am also looking for checkboxes, which i didn&#039;t get. could you please help me. 

i have an image, a checkbox, file name and a close img button aligned in a . on click of any part of the , the checkbox should be checked and css border should apply for whole  which i have clicked. if I click again on the same  the css should be remove and check box should be disabled.
(the  will be loaded dynamically and id will be unique each time it gets loaded)

please provide me with the code in jquery.

thank you in advance.

with regards,
Kiran Kumar.</description>
		<content:encoded><![CDATA[<p>Hi Barry,<br />
thank you for your post, i was just looking for this type of code for radio and checkboxes.</p>
<p>you have given code for radio button. i am also looking for checkboxes, which i didn&#8217;t get. could you please help me. </p>
<p>i have an image, a checkbox, file name and a close img button aligned in a . on click of any part of the , the checkbox should be checked and css border should apply for whole  which i have clicked. if I click again on the same  the css should be remove and check box should be disabled.<br />
(the  will be loaded dynamically and id will be unique each time it gets loaded)</p>
<p>please provide me with the code in jquery.</p>
<p>thank you in advance.</p>
<p>with regards,<br />
Kiran Kumar.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: keithics</title>
		<link>http://dev-tips.com/featured/jquery-tip-how-to-select-radiocheckbox-input-on-click#comment-720</link>
		<dc:creator>keithics</dc:creator>
		<pubDate>Mon, 11 May 2009 16:27:38 +0000</pubDate>
		<guid isPermaLink="false">http://dev-tips.com/?p=80#comment-720</guid>
		<description>thanks a lot! saves me time.

&quot;.children&quot; was the key!</description>
		<content:encoded><![CDATA[<p>thanks a lot! saves me time.</p>
<p>&#8220;.children&#8221; was the key!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: S.A.K</title>
		<link>http://dev-tips.com/featured/jquery-tip-how-to-select-radiocheckbox-input-on-click#comment-414</link>
		<dc:creator>S.A.K</dc:creator>
		<pubDate>Wed, 11 Mar 2009 06:52:29 +0000</pubDate>
		<guid isPermaLink="false">http://dev-tips.com/?p=80#comment-414</guid>
		<description>thanks for your code

really its coll dude</description>
		<content:encoded><![CDATA[<p>thanks for your code</p>
<p>really its coll dude</p>
]]></content:encoded>
	</item>
</channel>
</rss>
