jQuery | [attribute~=value] Selector
jQuery [attribute~=value] Selector Select all elements with a name attribute that contains the specific string.
Syntax:
$("[attribute~='string']")
Parameter:
- attribute: Specifies which attribute is used to find.
- string: Specifies the string value to find.
Example:
<!DOCTYPE html> <html> <head> <script src= </script> <script> $(document).ready(function() { $("input[name~='GFG']").css("background-color", "LIGHTGREEN"); }); </script> </head> <body> <input name="GFG" type="text" value="GEEKSFORGEEKS"> <input name="2" type="text" value="SITE1"> <input name="3" type="text" value="SITE2"> <input name="GFG" type="text" value="GEEKSFORGEEKS"> <input name="GFG" type="text" value="GEEKSFORGEEKS"> <input name="4" type="text" value="SITE4"> <input name="GFG" type="text" value="GEEKSFORGEEKS"> </body> </html> |
chevron_right
filter_none
Output:

Recommended Posts:
- jQuery | :has() Selector with example
- jQuery | :gt() Selector
- jQuery | :contains() Selector
- jQuery | :lt() Selector
- jQuery | :even Selector
- jQuery | :first Selector
- jQuery | :odd Selector
- jQuery | :last Selector
- jQuery | * Selector
- jQuery | :not() Selector
- jQuery | #id Selector
- jQuery | :submit Selector
- jQuery | [attribute$=value] Selector
- jQuery | :parent Selector
- jQuery | :file Selector
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



