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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:09:17+00:00 2026-05-31T05:09:17+00:00

I need to rewrite the html in 2 <p> tags when I check a

  • 0

I need to rewrite the html in 2 <p> tags when I check a checkbox. Note: the <div class="summary"> container repeats many times based on output from a DB.

* HTML *

<div class="summary">
    <div>Data 1</div>
    <div>Data 2</div>
    <div class="col_5"><input type="checkbox" /></div>
</div>
<div class="details">
    <p>label:</p><p>info</p>
    <p>label 2:</p><p>more info</p>
    <p class="jQuery1">another label to be changed:</p><p class="jQuery2">final info to be changed</p>
</div>

* JavaScript (everything works except comments 1 & 2) *

$(document).ready(function(){
    $('input:checkbox').change(function(event) {
        $(this).closest('div.col_5').html('Yes');
        $('div.details').next('p.jQuery1').html('Changed 1'); // c1 -- this does not work
        $('div.details').next('p.jQuery2').html('Changed 2'); // c2 -- this does not work
    });
    $('.summary').click(function(e){
        if ($("input:checked").length == 0) {
            $(this).next('.details').slideToggle('slow');
        }
    });
});
  • 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-31T05:09:18+00:00Added an answer on May 31, 2026 at 5:09 am

    The .next() method returns the next sibling of the element you call it on, but you are trying to find children of the element you call it on so you should use .children() (to retrieve only direct children) or .find() (to get descendants including children, grandchildren, etc.).

    Try the following:

    $('input:checkbox').change(function(event) {
        var $div = $(this).closest('div.col_5'),
            $nextDiv = $div.closest('div.summary').next('div.details');
        $div.html('Yes');
        $nextDiv.find('p.jQuery1').html('Changed 1');
        $nextDiv.find('p.jQuery2').html('Changed 2');
    });
    

    The reason I’m keeping a reference ($div) to the clicked checkbox’s parent div is because you need it to find the div afterwards and you won’t be able to use this after you’ve overwritten the div’s html with the string ‘Yes’ since that deletes the element that this refers to.

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

Sidebar

Related Questions

I have a need to rewrite all URLs except /admin/ to index.html. How would
all. I have an huge html file which contains tags like these: <h3 class=r>
I need to use C# Regex to do a link rewrite for html pages
I have following urls domain/jcb-wine{number}.html and i need to rewrite them like domain/wines/{number} I
I need rewrite this url http://adresa.com/article.php?act=view&id=1113 to http://adresa.com/view/1113 I make it with mod_rewrite in
I need to rewrite some Perl code in python. So I'm looking for the
I need to rewrite this query and I'm not allowed to use a subquery.
I need a rewrite in how the modifier 'truncate' is called, because it is
i have a mixed aspx/MVC webapp project and need to rewrite incoming URL's either
Here is a simplified version of the code I use. I need to rewrite

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.