Attribute exists $("[attributeName*='value']")

Description and Syntax

$("[attributeName*='value']");

selects by a string that exists anywhere in the attribute value.

Examples

The following code illustrates selecting any ID that contains "test" anywhere in the ID attribute value:


<!DOCTYPE html> 
<html>
    <head>
        <script src="http://java2s.com/style/jquery-1.8.0.min.js"> 
        </script>
        <script>
            var userInfo = $("[id*='test']").length; 
            document.writeln(n);
        </script> 
    </head> 
    <body>
        <div id="greentest"></div> 
        <div id="testman"></div> 
        <div id="myOdd"></div> 
    </body> 
</html><!-- w ww.  ja  va2s .  c  o  m-->

Click to view the demo

The code above generates the following result.

Attribute exists $("[attributeName*=