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 6074685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:24:35+00:00 2026-05-23T10:24:35+00:00

So, I’m having difficulty trying to append/add a child div to the parent div,

  • 0

So, I’m having difficulty trying to append/add a child div to the parent div, and thought someone out here may know the best way for me to go about this. I have attached my code (without PHP right now, just hard coding text and stuff). But here is what I am trying to do:

  • When a message is posted, you hit the “Reply Button” and a new div will appear underneath containing the reply form.

Right now, here are the issues I know about and can’t get around:

  • The DIV is a class, so when I use jQuery to try to target the DIV it targets everything since it’s no unique.

  • The Reply Button is also a class, so it’s not unique.

Here is a video of it in action: http://tinypic.com/r/2luxwnr/7

<body>
    <div id="content-container">
        <div id="message-viewer">
            <div class="roar">
                <div class="roaractionpanel">
                    <div id="msg-business2"></div>
                    <div class="roartime"><p class="roartime-text">3:26PM</p></div>
                </div>
                <div class="roarcontent">
                    <button type="submit" class="btn-reply"></button>
                    <h5>Test Post</h5><br>
                    <h6>Lord Varlin</h6><br>
                    <h2>Test post... let's see.</h2>
                </div>
            </div>
            <div class="newreply">
                <div class="newreplycontent">
                    <h1>This is where the fields for a new reply will go.</h1>
                </div>
            </div>


            <div class="roar">
                <div class="roaractionpanel">
                    <div id="msg-business2"></div>
                    <div class="roartime"><p class="roartime-text">3:26PM</p></div>
                </div>
                <div class="roarcontent">
                    <button type="submit" class="btn-reply"></button>
                    <h5>Testing another</h5><br>
                    <h6>Lord Varlin</h6><br>
                    <h2>Hmm dee dumm...</h2>
                </div>
            </div>
            <div class="roarreply">
                 <div class="roarreply-marker">
                    <p class="roarreplytime-text">June 26th @ 4:42AM</p>
                 </div>
                 <div class="roarreplycontent">
                    <h9>Testing a reply.  Hmmmm.</h9><br>
                    <h8>Lord Varlin</h8>
                 </div>
            </div>
            <div class="newreply">
                <div class="newreplycontent">
                    <h1>This is where the fields for a new reply will go.</h1>
                </div>
            </div>


            <div class="roar">
                <div class="roaractionpanel">
                    <div id="msg-business2"></div>
                    <div class="roartime"><p class="roartime-    text">3:26PM</p></div>
                </div>
                <div class="roarcontent">
                    <button type="submit" class="btn-reply"></button>
                    <h5>Testing another</h5><br>
                    <h6>Lord Varlin</h6><br>
                    <h2>jQuery, work with me please.</h2>
                </div>
            </div>
            <div class="roarreply">
                 <div class="roarreply-marker">
                    <p class="roarreplytime-text">June 26th @ 4:42AM</p>
                 </div>
                 <div class="roarreplycontent">
                    <h9>Testing a reply.  Hmmmm.</h9><br>
                    <h8>Lord Varlin</h8>
                 </div>
            </div>
            <div class="roarreply">
                 <div class="roarreply-marker">
                    <p class="roarreplytime-text">June 26th @ 4:42AM</p>
                 </div>
                 <div class="roarreplycontent">
                    <h9>Testing a reply.  Hmmmm.</h9><br>
                    <h8>Lord Varlin</h8>
                 </div>
            </div>
            <div class="newreply">
                <div class="newreplycontent">
                    <h1>This is where the fields for a new reply will go.</h1>
                </div>
            </div>
        </div>
    </div>
</body>

JQUERY

$(".btn-reply").click(function() {

    $(".newreply").toggleClass("show");
    return false;

 });

So, I see the flaws, but I just can’t wrap my head around how to pull this off! Any guidance would be awesome! 🙂

  • 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-23T10:24:36+00:00Added an answer on May 23, 2026 at 10:24 am

    Try:

    $('.btn-reply').click(function(){
        $(this).parents('.roar').siblings('.newreply').toggleClass('show');
        return false;
    });
    

    However, I agree with Francisc that a better approach would be to modify the HTML and assign a unique id to each message set. That way you can grab the .newreply to show based on a shared unique id which would be agnostic regarding the positioning of the HTML layout.

    E.g.

    <div class="roar" rel="msg0">...</div>
    ...
    <button class="btn-reply" rel="msg0"></button>
    ...
    <div class="newreply" rel="msg0">...</div>
    ...
    

    Then your jQuery becomes:

    $('.btn-reply').click(function(){
        var id = $(this).attr('rel');
        var selector = '.newreply[rel=' + id + ']';
        $(selector).toggleClass('show');
        return false;
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Does anyone know how can I replace this 2 symbol below from the string
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I'm trying to create an if statement in PHP that prevents a single post

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.