jQuery | [attribute|=value] Selector
The [attribute|=value] selector is used to select each element with a specific attribute, with a specific string value (like “geeks”) or starting string followed by a hyphen (like “geeks-forgeeks”).
Syntax:
$("[attribute|='value']")
Parameter :
- attribute : This parameter is required to specify the attribute to be searched.
- value : This parameter is required to specify the string the attribute value should start with.
Example-1:
<!DOCTYPE html> <html> <head> <script src= </script> <script> $(document).ready(function() { $("p[title|='GeeksForGeeks']").css( "background-color", "green"); }); </script> </head> <body> <center> <h1>Geeks For Geeks</h1> <p title="GeeksForGeeks"> Geeks1 </p> <p title="google"> Geeks2 </p> <p title="Tom"> Geeks3 </p> <p title="See You GeeksForGeeks"> Geeks4 </p> <p title= "GeeksForGeeks-is the best palce to learn"> Geeks5 </p> </center> </body> </html> |
chevron_right
filter_none
Output:

Example-2:
<!DOCTYPE html> <html> <head> <script src= </script> <script> $(document).ready(function() { $("p[title|='google']").css( "background-color", "green"); }); </script> </head> <body> <center> <h1>Geeks For Geeks</h1> <p title="GeeksForGeeks"> Geeks1 </p> <p title="google"> Geeks2 </p> <p title="google- tom"> Geeks3 </p> <p title="See You GeeksForGeeks"> Geeks4 </p> <p title= "GeeksForGeeks-is the best palce to learn"> Geeks5 </p> </center> </body> </html> |
chevron_right
filter_none
Output:

Recommended Posts:
- jQuery | * Selector
- jQuery | :first Selector
- jQuery | :even Selector
- jQuery | :not() Selector
- jQuery | #id Selector
- jQuery | :last Selector
- jQuery | :odd Selector
- jQuery | :has() Selector with example
- jQuery | :gt() Selector
- jQuery | :contains() Selector
- jQuery | :lt() Selector
- jQuery | :parent Selector
- jQuery | :hidden Selector
- jQuery | [attribute=value] 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.



