Home > Article > Web Front-end > What is jquery not equal to attribute selector
jquery is not equal to the attribute selector refers to the "[attribute!=value]" selector, which is used to select all elements where the specified attribute does not exist or the specified attribute value is not equal to a certain value.
The operating environment of this article: windows10 system, jquery 1.11.1, thinkpad t480 computer.
Recommended: "jquery Video Tutorial"
jquery attribute is not equal to the selector is the [attribute!=value] selector; used to select all specified attributes that do not exist or All elements whose specified attribute value is not equal to a certain value.
The selector treats the attribute value as an ordinary string (this is different from the class selector). For example, $('a[rel!=nofollow]') will match c138709809d5cab2cf1156cf8471345aSome text5db79b134e9f6b82c0b36e0489ee08ed.
The following code shows how to get all elements whose ID is not equal to cheese.
<!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script> </head> <body> <div id="eggs"></div> <div id="ham"></div> <div id="cheese"></div> <script> var n = $("[id!='cheese']").length; alert(n); </script> </body> </html>
The following code selects all input box elements whose input names are not me.
<html> <head> <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("input[name!='me']").next().text(" changed"); }); </script> </head> <body> <div> <input type="radio" name="you" value="A" /> <span>data</span> </div> <div> <input type="radio" name="me" value="B" /> <span>data</span> </div> <div> <input type="radio" name="me" value="C" /> <span>data</span> </div> </body> </html>
The above is the detailed content of What is jquery not equal to attribute selector. For more information, please follow other related articles on the PHP Chinese website!