removeClass where the internal link is a space

Asked

Viewed 11 times

0

I have the following HTML:

<div class="segura-li">
    <li class="classe-li">
       <a href="link1">texto</a>
    </li>
    <li class="classe-li">
       <a href="link2">texto</a>
    </li>
    <li class="classe-li">
       <a href="link3">texto</a>
    </li>
</div>

How to remove ONLY elemtno li that within the a have the URL link2?

If I do that I’ll remove all:

$('.segura-li').removeClass('.classe-li');
  • But you want to remove the element <li> or his class?

  • The element, I edited my question

  • 1

    If to remove the element, it can be $('.segura-li [href="link2"]').closest("li").remove()

  • And why did you use removeClass?

  • 1

    It may also be: $('[href="link2"]').closest("li").remove() if there is only this link on the page... there are several possibilities.... can be also $(".segura-li .classe-li:eq(1)").closest("li").remove()... Only that question contradicts what you just commented: "The element, I edited my question".

  • Just you have to answer what you want to do. The title of the question says one thing and the text says another.

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.