Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h1>Adjusted Selector</h1> <p>Modify the jQuery selector to:</p> <pre><code>&lt;script&gt; $('#level1 .noPad:gt(1)').remove(); //Or $(document).find('#level1 .noPad:qt(1)').remove(); &lt;/script&gt; </code></pre> <p><strong>Fiddle</strong>: <a href="http://jsfiddle.net/K5Q3B/6/" rel="nofollow noreferrer">http://jsfiddle.net/K5Q3B/6/</a></p> <p>Adjusted this after your previous selector was failing when more <code>&lt;div&gt;</code>s were introduced (See <a href="http://jsfiddle.net/K5Q3B/4/" rel="nofollow noreferrer">example Fiddle</a>). Alternatively, you could try what this person suggested in another <a href="https://stackoverflow.com/a/3373681/292735">SO Question</a>:</p> <pre><code>&lt;script&gt; $('#level1 .noPad').slice(3).remove(); &lt;/script&gt; </code></pre> <hr> <h2>Removing <em>Dynamically</em> loaded <code>&lt;div&gt;</code>'s</h2> <pre><code>&lt;script&gt; $.ajax({ .. //Other Opts success: function( data ) { $('#somediv').html( data ); var NodesToRemove = $(document).find('#level1 &gt; div:gt(1)'); //Or $('#somediv').find('#level1 .noPad:qt(1)').remove(); NodesToRemove.remove(); }); }); &lt;/script&gt; </code></pre> <hr> <h2>Prevention in PHP:</h2> <p>As others in the comments mentioned, it would be much better to prevent this in PHP - then you wouldn't need to consider any JavaScript for removing any of the <code>&lt;div&gt;</code>s at all,</p> <pre><code>$Counter = 0; if ( have_posts() ) { while ( have_posts() ) { $Counter++; the_post(); if ( $Counter &lt;= 2 ) get_template_part('new-story'); } } </code></pre> <p>Furthermore you could rewrite the PHP to have an AJAX Condition,</p> <pre><code>$Counter = 0; $isAjax = ( isset( $_GET["ajax"] ) &amp;&amp; $_GET["ajax"] == 'true' ? true : false ); if ( have_posts() ) { while ( have_posts() ) { $Counter++; the_post(); if ( !$isAjax || ( $isAjax &amp;&amp; $Counter &lt;= 2 )) get_template_part('new-story'); } } </code></pre>
    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.
 

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