Jquery addClass on radio box checked.
Posted
by Zoltan Repas
on Stack Overflow
See other posts from Stack Overflow
or by Zoltan Repas
Published on 2010-04-16T10:44:50Z
Indexed on
2010/04/16
10:53 UTC
Read the original article
Hit count: 324
I checked all the topics, but i simply don't know why my script does not work :(
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$('#pic').click(function() {
$(this).parents("li").find(".green").removeClass("green");
if($(this).is(':checked')) {
$(this).parents("ul").find("li").addClass('green');
}
});
</script>
etc...
<ul>
<li><input type="radio" name="pic" value="asd"/>asd</li>
<li><input type="radio" name="pic" value="b"/>asd</li>
<li><input type="radio" name="pic" value="ba"/>asd</li>
<li><input type="radio" name="pic" value="bs"/>asd</li>
<li><input type="radio" name="pic" value="bc"/>asd</li>
</ul>
Please help me!
© Stack Overflow or respective owner