checkbox - Jquery Swap checked disabled attr on change -
suppose check
disable
selected checkbox , reverse check
disable
on other box. seems work till try again on changed checkbox. brain fried today. grateful insight or better code.
$('.changecheck').change(function(event) { var oldtarget = $(':checked').attr('id'); console.log(oldtarget); $(this).attr('disabled', 'disabled').attr('checked', 'checked'); $('#'+oldtarget).removeattr('checked', 'checked').removeattr('disabled', 'disabled'); });
currently target second input, need target change
event on first input. should use prop() instead of attr()
:
$('.changecheck, #check1').change(function(event) { $(this).prop("disabled", true).siblings().prop("disabled", false).prop('checked', false); });
Comments
Post a Comment