Jquery addClass on radio box checked.
- by Zoltan Repas
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!