Filters out all elements matching the given selector.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <script src="../jquery-latest.js"></script> <script> $(document).ready(function(){ $("input:not(:checked) + span").css("background-color", "yellow"); $("input").attr("disabled", "disabled"); }); </script> </head> <body> <div> <input type="checkbox" name="a" /> <span>Mary</span> </div> <div> <input type="checkbox" name="b" /> <span>Paul</span> </div> <div> <input type="checkbox" name="c" checked="checked" /> <span>Peter</span> </div> </body> </html>
Perintah
$(“input:not(:checked) + span”).css(“background-color”, “yellow”);
digunakan untuk menset css backgroundColor: ‘yellow’ pada input checkbox yang tidak tercheck yang ada di document HTML.
Leave a Reply