Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to write jQuery prependTo for the result I want?
    primarykey
    data
    text
    <p>I have a question about jQuery prependTo. </p> <p>This is the html framework, and I can't change the framework. </p> <pre><code>&lt;section class="press-item"&gt; &lt;h2 class="press-title"&gt;press title 1&lt;/h2&gt; &lt;div class="press-author"&gt;Fraser Hughes&lt;/div&gt; &lt;div class="press-publisher"&gt;Evening Times&lt;/div&gt; &lt;time class="press-date" pubdate=""&gt;October 19, 2012&lt;/time&gt; &lt;div class="press-preview"&gt;press contain 1&lt;/div&gt; &lt;a class="press-more" href="" target="_blank"&gt;Read More&lt;/a&gt; &lt;/section&gt; &lt;section class="press-item"&gt; &lt;h2 class="press-title"&gt;press title 1&lt;/h2&gt; &lt;div class="press-author"&gt;Fraser Hughes&lt;/div&gt; &lt;div class="press-publisher"&gt;Evening Times&lt;/div&gt; &lt;time class="press-date" pubdate=""&gt;October 19, 2012&lt;/time&gt; &lt;div class="press-preview"&gt;press contain 1&lt;/div&gt; &lt;a class="press-more" href="" target="_blank"&gt;Read More&lt;/a&gt; &lt;/section&gt; &lt;/code&gt; </code></pre> <p>I want to add a <code>&lt;p&gt;&lt;/p&gt;</code> to wrap .press-autho, .press-publisher and press-date. The result should be like this:</p> <pre><code>&lt;section class="press-item"&gt; &lt;h2 class="press-title"&gt;press title 1&lt;/h2&gt; &lt;p&gt; &lt;div class="press-author"&gt;Fraser Hughes&lt;/div&gt; &lt;div class="press-publisher"&gt;Evening Times&lt;/div&gt; &lt;time class="press-date" pubdate=""&gt;October 19, 2012&lt;/time&gt; &lt;/p&gt; &lt;div class="press-preview"&gt;press contain 1&lt;/div&gt; &lt;a class="press-more" href="" target="_blank"&gt;Read More&lt;/a&gt; &lt;/section&gt; &lt;section class="press-item"&gt; &lt;h2 class="press-title"&gt;press title 1&lt;/h2&gt; &lt;p&gt; &lt;div class="press-author"&gt;Jeff Drake&lt;/div&gt; &lt;div class="press-publisher"&gt;Houston Chronicle&lt;/div&gt; &lt;time class="press-date" pubdate=""&gt;October 29, 2012&lt;/time&gt; &lt;/p&gt; &lt;div class="press-preview"&gt;press contain 2&lt;/div&gt; &lt;a class="press-more" href="" target="_blank"&gt;Read More&lt;/a&gt; &lt;/section&gt; </code></pre> <p>However, The result became like this</p> <pre><code> &lt;section class="press-item"&gt; &lt;h2 class="press-title"&gt;press title 1&lt;/h2&gt; &lt;p&gt; &lt;div class="press-author"&gt;Fraser Hughes&lt;/div&gt; &lt;div class="press-author"&gt;Jeff Drake&lt;/div&gt; &lt;div class="press-publisher"&gt;Evening Times&lt;/div&gt; &lt;div class="press-publisher"&gt;Houston Chronicle&lt;/div&gt; &lt;time class="press-date" pubdate=""&gt;October 19, 2012&lt;/time&gt; &lt;time class="press-date" pubdate=""&gt;October 29, 2012&lt;/time&gt; &lt;/p&gt; &lt;div class="press-preview"&gt;press contain 1&lt;/div&gt; &lt;a class="press-more" href="" target="_blank"&gt;Read More&lt;/a&gt; &lt;/section&gt; &lt;section class="press-item"&gt; &lt;h2 class="press-title"&gt;press title 1&lt;/h2&gt; &lt;p&gt; &lt;div class="press-author"&gt;Jeff Drake&lt;/div&gt; &lt;div class="press-publisher"&gt;Evening Times&lt;/div&gt; &lt;div class="press-publisher"&gt;Houston Chronicle&lt;/div&gt; &lt;time class="press-date" pubdate=""&gt;October 19, 2012&lt;/time&gt; &lt;time class="press-date" pubdate=""&gt;October 29, 2012&lt;/time&gt; &lt;/p&gt; &lt;div class="press-preview"&gt;press contain 2&lt;/div&gt; &lt;a class="press-more" href="" target="_blank"&gt;Read More&lt;/a&gt; &lt;/section&gt; </code></pre> <p>My code is </p> <pre><code>$(function () { var sources$ = $('&lt;p class="post-listmeta"&gt;&lt;/p&gt;'), targets$ = $('.press-title'), operation = 'after'; targets$[operation](sources$); $('.press-publisher').prependTo($('.post-listmeta')); $('.press-author').prependTo($('.post-listmeta')); $('.press-date').prependTo($('.post-listmeta')); }); </code></pre> <p>How do I writ the code that could be the result that I want?</p> <p>Thank you every one. </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.
    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