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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:16:32+00:00 2026-06-02T07:16:32+00:00

Im having a problem replacing content of a div when a link is clicked.

  • 0

Im having a problem replacing content of a div when a link is clicked. Im able to replace the content once but not able to do it a second time. I think Im not able to get a handle of the id of the new div.

Take a look at my example

Click on Show Group 1 and then show group 2. I can replace them both but not able to replace Group 1 again. Refresh the page to see the process again.

Any help is appreciated.

  • 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-06-02T07:16:35+00:00Added an answer on June 2, 2026 at 7:16 am

    Your problem is with replaceWith() you are replacing the code you are using as a handle …

    $j(".monitoringDesc").click(function(e) {
        e.preventDefault();
        $j(".widgetGroup").html($j("#newGroup").html());
        $j(".widgetGroup").show("slide", {
            direction: "right"
        }, 200);
    });
    

    this keeps the container widgetGroup in tact – just replacing the contents using .html()

    Here is an example of both working using this method

    Update

    You could make you code and function a little more generic … first add some data to the HTML :

    <li><a href="#" class="monitoringDesc" data-target="newGroup">Show group 1</a></li>
    <li><a href="#" class="monitoringDesc" data-target="newGroup2">Show group 2</a></li>
    

    all I have added is the 2 data-target attributes – then the following jQuery will pull in the content you require based on the above data

    $j(".monitoringDesc").click(function(e) {
        e.preventDefault();
        $j(".widgetGroup").html($j("#"+$j(this).data('target')).html());
        $j(".widgetGroup").show("slide", {
            direction: "right"
        }, 200);
    });
    

    this uses the .data() method to extract the data-target property from the HTML above. I also changed the class of the anchors to match – so we can listen to the click event on both.

    Working example of this solution here

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

Sidebar

Related Questions

Having problem with the middle Div not expanding to the width http://acs.graphicsmayhem.com/images/middiv.jpg Ok, how
i'm having a problem replacing ==> ’ (apostrophe) with a space i know it
I'm having a problem with a file download where the download is replacing all
I'm playing around with finding and replacing text. The only problem I'm having is
I'm having problem with replacing objects inside NSMutableArray which is an object inside another
I am having problem with my listview, the data is perfectly working but when
I'm having a problem relating to Sharepoint workflows and the associated task list. I
I'm having problem when running my Windows Forms program. In the program, I have
I'm having problem with Rails plugin attachment_fu . On every upload, I get validation
i'm having problem to deal with charset in ruby on rails app, specificially in

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.