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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T12:12:45+00:00 2026-06-05T12:12:45+00:00

I am using innerHTML to assign updated value to certain elements on a page.

  • 0

I am using innerHTML to assign updated value to certain elements on a page. However, the innerHTML caused the jquery on the page stopped working, and the css of the page runs out.

So I tried to replace with DOM elements but it’s not working. Any idea how to fix this?
Thanks !

var names =['id','name','quantity','description']; 
    var len = names.length;
    for (var i = 0; i < len; i++){
        var el = document.getElementById(\'product_\'+names[i]+\'_main\');  
        var el2 = document.getElementById(\'product_\'+names[i]+selection);
       if(el.hasChildNodes()) {                                 
         el.replaceChild(el2.firstChild.nodeValue, el.firstChild);
       } 
      if(el && el2) el.innerHTML=el2.innerHTML; /* this part works, but it caused the page CSS to run and jquery no longer working */
      }
  • 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-05T12:12:46+00:00Added an answer on June 5, 2026 at 12:12 pm
    el.replaceChild(el2.firstChild.nodeValue, el.firstChild);
    

    Huh, what are you doing there? You can’t replace a nodeValue, you can only replace nodes:

    el.replaceChild(el2.firstChild, el.firstChild);
    

    this will move the firstChild of el2 into el. If you want to copy it, you’d need to clone it before. If you want all of the children, you’d need to loop over them.

    If that firstChild is a text node, you can easily (re)set its value, and copy those of el2:

    if (el.firstChild && el.firstChild.nodeType == 3
      && el2.firstChild && el2.firstChild.nodeType == 3)
        el.firstChild.nodeValue = el2.firstChild.nodeValue;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How could I achieve the following: document.all.regTitle.innerHTML = 'Hello World'; Using jQuery where regTitle
I have writen options to a <select> using something like Id.innerHTML = <option value='foo'>Foo</option>;
Using a CSS image sprite, I'm creating an 'interactive' image where hovering over certain
I want to assign a csharp variable to the element of asp page using
I tried to load some scripts into a page using innerHTML on a <div>
I've been using innerHTML and innerText for a while to change elements and text
I have created an object at runtime by using innerHTML tag, now I want
I am having issues passing a dynamic parameter to a JavaScript function using innerHTML.
I want to do some innerHTML replacements, but using PHP includes, I dont get
i am developing a gadget and i am using JavaScript to change innerHTML of

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.