Saturday, 28 September 2013

How to make jQuery recognize radiobutton change

How to make jQuery recognize radiobutton change

I have two radio buttons, first makes the text red, the other makes it
yellow. but i cant make it blue. please help thanks.
Solution: http://jsfiddle.net/h6ye7/17/
<form>
Option 1<input type="radio" name="opt" class="radio1" value="Option 1" />
Option 2<input type="radio" name="opt" class="radio1" value="Option 2" />
</form>
<div class="text">sad dsffsadf sdsdf sfadfsd</div>
$(document).ready(function(){
$('input[type=radio]').change(function(){
if($('.radio1').is(':checked'))
{
$('.text').css('background-color', 'red');
}
else
{
$('.text').css('background-color', 'yellow');
}
});
});

No comments:

Post a Comment