Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

99
Views
How can I use jQuery line by line

I want to display comments line by line in a div but the div is closing first and after that the comments are listing.

if (comments.num_replies > 0) {
    $("#showComment").append(`<div id="replyContainer${comments.comment_id}" class="replyContainer">`);

    comments.comment_replies.forEach((replies) => {
        $("#showComment").append(`
            <div class="img-comment reply">
                <img src="${home_url}img/user.png">
                <div class="m-2 p-3 ">

                    <div class="user-date"><p class="username">@${replies.replier_username}</p><p class="date">${replies.dates}</p></div>
                    <p class="comment_content">${replies.reply_comment_content.replace(/\n/g, "<br>")}</p>
                </div>
            </div>
        `)
    });

    $("#showComment").append(`</div>`);
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can try something like this

if (comments.num_replies > 0) {
    let replies = comments.comment_replies.map((replies) => (
        `<div class="img-comment reply">
            <img src="${home_url}img/user.png">
            <div class="m-2 p-3 ">

                <div class="user-date"><p class="username">@${replies.replier_username}</p><p class="date">${replies.dates}</p></div>
                <p class="comment_content">${replies.reply_comment_content.replace(/\n/g, "<br>")}</p>
            </div>
        </div>`
    ));

    $("#showComment").append(`<div id="replyContainer${comments.comment_id}" class="replyContainer">${replies.join('')}</div>`);
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!