The jQuery disabled selector selects all elements that are disabled. It is recommended to precede pseudo-class selectors (those that begin with a “:”) with a tag name or some other selector; otherwise, the universal selector (“*”) is implied. In other words, the bare $(‘:disabled’) is equivalent to $(‘*:disabled’), so $(‘input:disabled’) should be used instead.
Source Code
<!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery-latest.js"></script> </head> <body> <div id="div1"> <input type="checkbox" disabled="disabled"/> checkbox 1 <input type="checkbox" /> checkbox 2 </div> <div id="div2"> <input type="checkbox" /> checkbox 3 <input type="checkbox" disabled="disabled"/> checkbox 4 </div> <button>Click Here</button> <script> jQuery("button").click(function () { jQuery("input:disabled").wrap('<span></span>').parent().css({border:"3px #1E8CBE solid"}); }); </script> </body> </html>
Demo
Following example finds all input elements that are disabled and create a border around them.
checkbox 1
checkbox 2
checkbox 2
checkbox 3
checkbox 4
checkbox 4
No comments yet.