How to use variable in JQuery select -


how modify jquery use var instead of '12'?

    var disableid = 12;      if (e.currenttarget.checked) {          $("input:checkbox[value=12]").attr("disabled", true);     }     else {         $("input:checkbox[value=12]").attr("disabled", false);     } 

you should use jquery's prop() method instead of attr() boolean values; there's no need if statements @ can set disabled state equal e.currenttarget.checked (which either true or false):

var disableid = 12,     state = e.currenttarget.checked;  $("input:checkbox[value='" + disableid + "']").prop("disabled", state); 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -