jQuery attribute exists selector

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><!--from ww  w.ja  va  2 s . c  o  m-->

Click to view the demo





















Home »
  jQuery »
    jQuery Tutorial »




Basics
Selector
DOM
Event
Effect
Utilities