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

  • Home
  • SEARCH
  • 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 182521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:57:16+00:00 2026-05-11T14:57:16+00:00

EDIT: WOW. This question is 12 years old now. As someone stated, it can

  • 0

EDIT: WOW. This question is 12 years old now.

As someone stated, it can be done with a one-liner since 2016: https://stackoverflow.com/a/69322509/80907


The original:

I’m wondering if there’s a way to change the text of anything in HTML without using innerHTML.

Reason I’m asking is because it’s kinda frowned upon by the W3C. I know it’s nitpicking, but I just wanna know, is there a way?

EDIT: people seem to misunderstand what I’m asking here: I want to find a way to effectivly change the text being displayed.

If I have:

<div id="one">One</a> 

innerHTML allows me to do this:

var text = document.getElementsById("one"); text.innerHTML = "Two"; 

And the text on my screen will have changed.
I do not wish to append more text, I wish to change allready existing text.

  • 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. 2026-05-11T14:57:16+00:00Added an answer on May 11, 2026 at 2:57 pm

    The recommended way is through DOM manipulation, but it can be quite verbose. For example:

    // <p>Hello, <b>World</b>!</p> var para = document.createElement('p'); para.appendChild(document.createTextNode('Hello, '));  // <b> var b = document.createElement('b'); b.appendChild(document.createTextNode('World'); para.appendChild(b);  para.appendChild(document.createTextNode('!'));  // Do something with the para element, add it to the document, etc. 

    EDIT

    In response to your edit, in order to replace the current content, you simply remove the existing content, then use the code above to fill in new content. For example:

    var someDiv = document.getElementById('someID'); var children = someDiv.childNodes; for(var i = 0; i < children.length; i++)     someDiv.removeChild(children[i]); 

    But as someone else said, I’d recommend using something like jQuery instead, as not all browsers fully support DOM, and those that do have quirks which are dealt with internally by JavaScript libraries. For example, jQuery looks something like this:

    $('#someID').html('<p>Hello, <b>World</b>!</p>'); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: had to retag this, because, it's rather a Sweave / R question since
Edit: This question was written in 2008, which was like 3 internet ages ago.
EDIT: This question is more about language engineering than C++ itself. I used C++
EDIT: upgraded this question to MVC 2.0 With asp.net MVC 2.0 is there an
Edit: This is technically a 2 part question. I've chosen the best answer that
Edit: From another question I provided an answer that has links to a lot
EDIT: This was formerly more explicitly titled: - Best solution to stop Kontiki's KHOST.EXE
edit #2: Question solved halfways. Look below As a follow-up question, does anyone know
Edit: This was accidentally posted twice. Original: VB.NET Importing Classes I've seen some code
Edit: I have solved this by myself. See my answer below I have set

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.