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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:47:21+00:00 2026-05-27T07:47:21+00:00

HTML: <ul id=datalist> </ul> JavaScript: function add(content){ ul=document.getElementsByTagName(ul); var li=document.createElement(li); li.innerHTML=content; ul.appendChild(li); } When

  • 0

HTML:

<ul id="datalist">
</ul>

JavaScript:

function add(content){
   ul=document.getElementsByTagName("ul");
   var li=document.createElement("li");
   li.innerHTML=content;
   ul.appendChild(li);
}

When I call add, Uncaught TypeError: Object #<NodeList> has no method 'appendChild' is thrown. Any idea why?

  • 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-27T07:47:21+00:00Added an answer on May 27, 2026 at 7:47 am

    getElementsByTagName() does not return one element, it returns a NodeList, which is an array-like object. It basically means you can use it as an array.

    So you could do for example:

    var ul = document.getElementsByTagName("ul")[0];
    

    But why don’t you simply use getElementById(), if that list has an ID anyways? IDs must be unique in the whole document, so this method will only return one element.

    var ul = document.getElementById('datalist');
    

    Note: Please be sure to declare ul as a local variable to your function (add var), unless you mean to use it outside the function.

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

Sidebar

Related Questions

HTML: <script type=text/javascript> var x = overriden; </script> <script src=myjs.js></script> myjs.js: $(document).ready(function(){ var x
Html.Encode seems to simply call HttpUtility.HtmlEncode to replace a few html specific characters with
HTML Javascript question to get the selected value of a input-select I can use
Html can contain little bits of Javascript embedded in it (e.g. defined in onclick
I would like to mimic the RepeatColumn function of the ASP.NET DataList control in
For example in my datalist if Eval(OptionJ).Tostring = Null I would like the function
Html <div class=lang-currency-field> <div class=lang-currency-links>links here</div> </div> jQuery <script> $('.lang-currency-button').click(function() { $('.lang-currency-field').fadeIn(); }); $('.lang-currency-links').click(function()
How to check if html element is supported, datalist for example? MDC says it
I am using a Datalist using SqlDatasource on a usercontrol. Below is the html
Using DataList, it's not possible to collect data into a <textarea></textarea> HTML tag. Because

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.