Javascript examples for jQuery Selector:attribute containing substring
The [attribute*=value] selector selects elements with attribute containing a substring.
Parameter | Description |
---|---|
attribute | Required. attribute to find |
value | Required. contained string value |
The following code shows how to select all <input> elements with a name attribute that contains the word "test":
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("input[name*='test']").css("background-color", "red"); });//w w w. j a v a2s. c o m </script> </head> <body> <input name="test" type="text" value="test"> <div name="test">test</div> <input name="tests" type="text" value="tests"> <input name="test case" type="text" value="test case"> </body> </html>