[attribute*=value] Selector - Javascript jQuery Selector

Javascript examples for jQuery Selector:attribute containing substring

Description

The [attribute*=value] selector selects elements with attribute containing a substring.

Syntax

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":

Demo Code

ResultView the demo in separate window

<!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>

Related Tutorials