jquery - Removing/Hiding a li href link within a DIV -


i need hide/remove link (team.aspx) within drop down menu added in later on. heres code:

<div id="nav_menu"> <ul id="nav">     <li class="current"><a href="home.aspx">home</a> </li>     <li><a href="iam.aspx">i a...</a>     <ul>     <li><a href="whoweare.aspx">who are</a>     <ul>         <li><a href="profile.aspx">our experience</a> </li>         <li><a href="team.aspx">our team</a></li>         <li><a href="mission.aspx">mission, values, vision</a></li>         <li><a href="strength.aspx">strengthening communities</a></li>         <li><a href="stories.aspx">where stories made</a></li>     </ul>  </div> 

first, tried remove <li> using pseudo worked removed <li> in each second position: nav li ul li:nth-child(2) { display: none; }

next, tried jquery know i'm missing something, need please:

(function($) {       $(document).ready(function(){         $("#nav li ul li:has(a[href='team'])").remove();     }); })(jquery); 

maybe typo in question, have { should have [.

$(document).ready(function(){      $("#nav li ul li:has(a[href='team'])").remove();     // -------------------^ }); 

aside that, it's hard know correct answer without seeing markup.


edit:

if you're going use attribute-equals-selector(docs) selector, needs exact match.

so this:

$("#nav li ul li:has(a[href='team'])").remove(); 

should be:

$("#nav li ul li:has(a[href='team.aspx'])").remove(); 

or alternative, use attribute-starts-with-selector(docs) .

$("#nav li ul li:has(a[href^='team'])").remove(); 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -