Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove all tags after certain tag?

I need to remove tags going after #first and only in #container. How can I do it with jQuery?

<div id="container">
  <div id="first"></div>
  <div id="remove_me_1"></div>
  <div id="remove_me_2"></div>
  <div id="remove_me_3"></div>
  <a href="" id="remove_me_too">Remove me too</a>
</div>

Thank you

like image 662
Kirzilla Avatar asked May 12 '10 10:05

Kirzilla


People also ask

How do you unlink a tag?

Tap Photos you're tagged in. Tap the photo you want to hide. Tap to open the photo, then tap to the right of the photo. Tap Remove Tag.

How do I select all tags?

The * selector selects all elements. The * selector can also select all elements inside another element (See "More Examples").

How do you remove tags in HTML?

Approach: Select the HTML element which need to remove. Use JavaScript remove() and removeChild() method to remove the element from the HTML document.

How do I remove a tag from a document?

Un-tag an item: Control-click it or tap it with two fingers, then choose Tags. Select the tag you want to remove, then press Delete. To remove every instance of a tag from all files and folders, choose Finder > Preferences, then click Tags.


2 Answers

You can use nextAll method: http://api.jquery.com/nextAll/

$("#first").nextAll().remove();
like image 137
mamoo Avatar answered Sep 27 '22 01:09

mamoo


$.("#container #first ~ *").remove();
like image 31
Emil Vikström Avatar answered Sep 26 '22 01:09

Emil Vikström