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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:33:34+00:00 2026-05-28T14:33:34+00:00

I have some javascript that looks like this: var sel = ‘<option value={value} {selected}>{name}</option>’;

  • 0

I have some javascript that looks like this:

var sel = '<option value="{value}" {selected}>{name}</option>';
...
$(index + '_expiry').innerHTML = sel; // $(index + '_expiry) is a select.

This works fine in firefox, but not in Internet Explorer – not even IE9.

There is already a solution to this problem that involves creating new elements in the DOM rather than changing the innerHTML.

Is it wrong to insert new elements into a page by manipulating .innerHTML? I use the innerHTML approach all over my site and it is easy. It works in IE for simple elements like .div too.

Though IE is often annoying to work with, the newer versions have a stricter javascript parser that is probably more correct – for instance, it doesn’t like an array created as ['a','b','c',].

So, is it bad, inefficient, unreliable, or similar to use .innerHTML to create new HTML elements in the DOM? Should I use it for only inserting plain text? Or is this just IE benig stubborn?

  • 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-28T14:33:35+00:00Added an answer on May 28, 2026 at 2:33 pm

    So, is it bad

    Subjective

    inefficient

    Usually more efficient then the alternatives in terms of run time. The cost comes from making sure the strings are properly constructed.

    unreliable

    Browsers are consistent (although not always with other browsers), so you can rely on decently tested code.

    Or is this just IE benig stubborn?

    IE doesn’t like editing the insides of certain elements (tables and select elements in particular).

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

Sidebar

Related Questions

I have some very simple javascript code that looks like this: var newWindow =
Here is the situation. I have some javascript that looks like this: function onSubmit()
In my aspx file, I have some code that looks like this: <script type=text/javascript>
I've got some JavaScript in an ASP.NET page that looks like this: var list
I have HTML that looks like this: <form id=kinodForm> <input type=text name=element[5] value=krispy kreme
I have some third-party Javascript that has statements like this: FOO = function() {
I have some HTML that looks like this: <div class=MyClass></div> <div class=MyClass></div> <div class=MyClass></div>
I have a Javascript object that (very simplified) looks like this if('undefined' !== typeof(listCtrls)){
I have some code that looks something like this: <head runat="server"> <script type="text/javascript"> var
I have some javascript code like this, var worker = new Worker(javascript/worker.js); worker.onmessage =

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.