javascript - button attribute "disable" not working -
in fiddle here:http://jsfiddle.net/qjdaa/2/ code suppose disable #monitor button when there none checked checkbox.
var checked = $('#status_table tr [id^="monitor_"]:checked'); if (checked.index()==-1){ $('#monitor').attr('disabled','true'); } but not seem working. what's wrong?
edit: found out i'm getting blurred code. simplify whole thing, may should change logic :s how should if want enable monitor button if there @ least checkbox been checked?
try using condition:
if (checked.length === 0) { and should use .prop(), not .attr() setting disabled state (as things checked , selected).
so be:
$("#monitor").prop("disabled", true); // (or false, enable it) references:
.prop()vs..attr(): .prop() vs .attr().prop(): http://api.jquery.com/prop/
Comments
Post a Comment