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:


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -