Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3932682
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:31:01+00:00 2026-05-19T23:31:01+00:00

I have a DOM structure that looks like this: <div id=comment-1234 class=comment>…</div> <div id=comment-2391

  • 0

I have a DOM structure that looks like this:

<div id="comment-1234" class="comment">...</div>
<div id="comment-2391" class="comment">...</div>
<div id="comment-1223" class="comment reply">...</div>
<div id="comment-1221" class="comment reply">...</div>
<div id="comment-2333" class="comment">...</div>
<div id="comment-1235" class="comment reply">...</div>
<div id="comment-3333" class="comment reply">...</div>
<div id="comment-5555" class="comment">...</div>

In my javascript, I’ll have the ID of the div that is getting a new reply, eg comment-2391. What I need to do is find that comments last reply, and insert a new div after that. The script is currently using append('#comment-1234') and that is working just fine, but it inserts it at the top of the replies.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T23:31:02+00:00Added an answer on May 19, 2026 at 11:31 pm

    Try this:

    $('#comment-2391').nextUntil(':not(.reply)').last().after(newcomment); 
    

    where newcomment is the new DIV that you want to insert

    Demo: http://jsfiddle.net/DaX94/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dom structure that looks something like (although a lot more complex)
I have the following DOM structure: /*:DOC += <div id='testDiv' class='testDivClass'><div id='innerTestDiv'></div></div><span id='testSpan' class='testSpanClass'><span
I have the following DOM structure: <div class=city> <div class=a>Delete</div> <div class=b>Selected</div> <div class=c>Delete</div>
So if I have a DOM like this : <div id=foo> <ul><li><a href=#></a></li></ul> </div>
I have a theoretical grid of overlapping rectangles that might look something like this:
I have a javascript function that manipulates the DOM when it is called (adds
In using PHP's DOM classes (DOMNode, DOMEElement, etc) I have noticed that they possess
Premise: I've started to study javascript and the DOM and I have this HTML
I have DOM elements I'd like to exclude from a .click function by adding
I have the following DOM structure / HTML, I want to get (just practicing...)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.