Reputation: 2926
I have a markup something similar to below -
<div class="nav" id="nav">
<ul>
<li><a href="">------</a></li>
<li><a href="">------</a></li>
<li><a href="">------</a></li>
<li>
<a class="mainMenuLink" href="index.php?p=account-information"><i class="fa fa-cog fa-3x"></i> Account Information<span class="fa arrow"></span></a>
</li>
<li>
<a class="active-menu" href="index.php?p=account-function"><i class="fa fa-cog fa-3x"></i> Account Functions<span class="fa arrow"></span></a>
<ul class='nav nav-second-level in'>
<li>
<a class="subMenuLink" href="index.php?p=create-account">Create a New Account</a>
</li>
<li>
<a class="active" href="index.php?p=modify-account-select">Modify an Account</a>
</li>
<li>
<a class="subMenuLink" href="index.php?p=">Password Modification</a>
</li>
</ul>
</li>
</ul>
</div>
In this markup I want to select tags that contains 'Account Fuction' and 'Modify an Account'.
This is what I want to select from about Markup -
<a class="active-menu" href="index.php?p=account-function"><i class="fa fa-cog fa-3x"></i> Account Functions<span class="fa arrow"></span></a>
<a class="active" href="index.php?p=modify-account-select">Modify an Account</a>
Can somebody tell me what is the best way to select these elements in jquery?
Hope somebody may help me out. Thank you.
Upvotes: 0
Views: 72
Reputation: 21565
You can just do this:
$("a:contains('Account Functions')");
$("a:contains('Modify an Account')");
This way it will find the elements no matter where they are. jQuery is nice isn't it?
Upvotes: 3
Reputation: 1891
You can try this code $(".active-menu, .active")
You can select class active-menu or class active in one statement
Upvotes: 0
Reputation: 1883
$("#nav").children("ul li").find(".yourelementclass").text();
You can do something like that.
Upvotes: 0