Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>EDIT:</strong> Based on your update, I see that you only want to remove certain elements based on a potentially matching ID, and that there could be several matches of each type.</p> <p>You can do this instead:</p> <p><a href="http://www.jsfiddle.net/JfPQ7/"><i><b>Click here to test a working example.</b> <sup>(jsFiddle)</i></sup></a></p> <pre><code>var found = {}; // Container to hold each unique ID that we find. $('div[id^=EXTRACTION_]').filter(function() { var ending = this.id.replace("EXTRACTION_",""); if( found.hasOwnProperty( ending ) ) { return this; } else { found[ ending ] = ending; } }).remove(); </code></pre> <p>Basically using the <a href="http://api.jquery.com/attribute-starts-with-selector/"><code>attribute-starts-with-selector</code><sup><i>(docs)</i></sup></a> we select all elements that start with <code>EXTRACTION_</code>. <em>(I also added the <code>div</code> to the selector. If they're not all <code>divs</code>, remove that.)</em> </p> <p>Then we <a href="http://api.jquery.com/filter/"><code>filter()</code><sup><i>(docs)</i></sup></a> them. In the filter, first we extract the unique part of the ID. Then we check to see if that ID is a property of an object we created called <code>found</code>. If it isn't, add it as a property. If it is already a property, that means we already came across it, so we do <code>return this</code>, which will cause the <code>.filter()</code> to keep that element in the set.</p> <p>So at the end, we're left with only those elements that are duplicates, and we can then do a <a href="http://api.jquery.com/remove/"><code>remove()</code><sup><i>(docs)</i></sup></a>.</p> <hr> <p><strong>Original:</strong></p> <p>This will take care of your duplicates for you.</p> <p><a href="http://api.jquery.com/jquery/"><code>$(</code></a><a href="http://api.jquery.com/element-selector/"><code>'div</code></a><a href="http://api.jquery.com/child-selector/"><code>&gt;</code></a><a href="http://api.jquery.com/element-selector/"><code>div'</code></a><a href="http://api.jquery.com/jquery/"><code>)</code></a><a href="http://api.jquery.com/remove/"><code>.remove()</code></a></p> <hr>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload