I have created a plugin where in I replace standard checkbox with iPhone like slide button. I'm able to bind the button with checkbox, i.e. when I click on YES button, checkbox is checked and when I click on NO button, checkbox is unchecked. Similarly I have created a plugin for radio button too. Now the problem is, if someone check the checkbox using jquery or select the radio button using jquery, how do I listen to this event and change corresponding button I have created using plugin, given that I don't have control over code which selects the radio button.
Sample code (I want change event to be called on click of button, given that I don't control click of button. Basically I want to listen to the event):
<input type="radio" name="radio" id="radio1"> Radio 1 </BR>
<input type="radio" name="radio" id="radio2"> Radio 2 </BR>
<input type="radio" name="radio" id="radio3"> Radio 3 </BR>
<button>click me</button>
$('input:radio').change(function(){
alert($(this).attr('id') + ' is changed');
});
$('button').click(function(){
$('#radio1').prop('checked', 'true');
});
prop
instead of a string! – ThiefMaster♦ Apr 7 '13 at 8:42