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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:34:54+00:00 2026-06-01T06:34:54+00:00

for an li tag i am adding a div with multiple div dynamically like

  • 0

for an li tag i am adding a div with multiple div dynamically like below.

 var divStr = "";
 divStr = divStr + "<div id='divTaskDetail"+id+"'>";
 divStr = divStr + "<div id='div1"+id+"'>.......</div>";
 divStr = divStr + "<div id='div2"+id+"'>.......</div>";
 divStr = divStr + "<div id='div3"+id+"'>.....<input class='btnSave' type='button' value='Save'  onclick='javascript:SaveTaskDetails(" + id + ")'/></div>";
 divStr = divStr + "<div id='div4"+id+"'>.......</div>";
 divStr = divStr + "</div>";

 $("#liTask"+id+"").append(divStr);

For the “save” button click in “div3” i want to refresh the “div3” region only. ie to rebind the div3 in the same position.
My code for getting the “div3” is below

    function SaveTaskDetails(id)
    {
         var CheckDivObj = $("#liTask"+id+"").children();
         var childNode = CheckDivObj.prevObject[0];
         var childTaskNode = childNode.childNodes[1];
         var childSubTaskNode = childTaskNode.children[3];
         if(childSubTaskNode != null)
         {
             $(""+childSubTaskNode.id+"").detach();
         }
    }

I can get the div3 in childSubTaskNode but i want to remove it and rebind in the same position. Is this posible…..
if so a sample code for detaching and rebinding at same position will be helpfull
Thanks in advance

  • 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-01T06:34:55+00:00Added an answer on June 1, 2026 at 6:34 am

    I would do an ajax function to get the new div contents and then use the html function in jquery to change the html of the div you want to update.

    $('#div3_save_button').click(function(){
        $.ajax({
            url:'my_script.php',
            type:'post',
            data:'data=some_data',
            success:function(data){
                // the data variable will contain proper html string for content of div 3, returned from my_script.php
                $('#div3').html(data);
            }
        });
    });
    

    This way we do not have to remove and replace div3, just replace the contents of div 3. See docs for html here

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

Sidebar

Related Questions

I'm dynamically adding value of an input tag. The values are returned from the
I am adding img tag dynamically in a container div. While creating img i
i am creating XmlDocument by code and adding some tag. The structure is like
Is there a capture the onload event when dynamically adding a script tag with
I have div tag with css class name. div class name is same in
Clicking on my anchor tag, shown below, does not hide the notify-parent div. The
I have a div tag in my modal dialog built using JQuery like this:
When adding a bookmark or favorite the browser uses the TITLE tag of the
I'm adding Facebook Open Graph meta tag to my site. For example: <meta property=og:image
I use tag-it plugin from https://github.com/aehlke/tag-it/downloads . How to disable adding new tags? $(document).ready(function

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.