Posted: 4/2/2010
I have various anchor tags on my page . Now I need to select only those anchors which have class name "highlight" and id containing "menu" text.
I need to do the above with jquery . I know this syntax
$("a[class=highlight]")
But the issue is how to match the other one.
Posted: 4/19/2010
<html xmlns="http://www.w3.org/1999/xhtml" > <head > <title></title> <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script> </head> <body> <a href="#" id="menu1" class="light">a1</a> <a href="#" id="a2" class="highlight">a2</a> <a href="#" id="menu2" class="highlight">a3</a> <a href="#" id="a4" >a4</a> <a href="#" id="menu3" class="highlight">a5</a> </body> <script type="text/javascript"> $(function () { var anchors = $('a[id*=\'menu\'][class=\'highlight\']'); //now test it $.each(anchors, function (index, anchor) { alert(anchor.id); }); }); </script> </html>