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

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -