Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery - insert div after div
    primarykey
    data
    text
    <p>I'm trying to add detail information after somebody clicks on an item on my site. </p> <p>Here's my regular code (it is Bootstrap 3):</p> <pre><code>&lt;div class="container"&gt; &lt;div class="row"&gt; &lt;div class="col-sm-6 col-md-4 col-xs-12"&gt; &lt;div class="portfolio_item"&gt; &lt;!-- Info --&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="col-sm-6 col-md-4 col-xs-12"&gt; &lt;div class="portfolio_item"&gt; &lt;!-- Info --&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="col-sm-6 col-md-4 col-xs-12"&gt; &lt;div class="portfolio_item"&gt; &lt;!-- Info --&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="row"&gt; &lt;!-- Same as above --&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>When somebody clicks a portfolio_item there should come a new <code>div</code> after the row the person clicked on.</p> <pre><code>$('.portfolio_item').click(function(){ var row = $(this).parent().parent(); row.after('&lt;/div&gt;&lt;div class="detailview"&gt;Detail Information&lt;/div&gt;&lt;div class="container"&gt;'); } </code></pre> <p>As you can see, I break out of the container. That part doesn't work. When I log the source code of my page. This is what I see:</p> <pre><code>&lt;div class="container"&gt; &lt;div class="row"&gt; &lt;!-- Same Row Info --&gt; &lt;/div&gt;&lt;div class="detailview"&gt;Detail Information&lt;/div&gt;&lt;div class="container"&gt;&lt;/div&gt; &lt;div class="row"&gt; &lt;!-- Same Row Info --&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>As you can see, it looks like it is added before the end of <code>.row</code> (like <code>append()</code>) instead of after it. When I insert it manually on the page, it works fine. Any idea how I should fix this?</p> <p><strong>Solved:</strong> Since I couldn't find a really good answer, here's how I solved it: I break out of the <code>.container</code> after every <code>.row</code> and don't add my <code>.detailview</code> after the <code>.row</code> but after the <code>.container</code>.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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