OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Create node list from a single node in JavaScript

  • Thread starter Thread starter Randy Hall
  • Start date Start date
R

Randy Hall

Guest
This is one of those it seems so simple, but I cannot come up with a good way to go about it.

I have a node, maybe nodelist = document.getElementById("mydiv"); - I need to normalize this to a node list. And not an array either: an actual, bona-fide nodeList object.

Not nodelist = [document.getElementById("mydiv")];

No libraries, please.

<p>This is one of those it seems so simple, but I cannot come up with a good way to go about it.</p>

<p>I have a node, maybe <code>nodelist = document.getElementById("mydiv");</code> - I need to normalize this to a node list. And not an array either: an actual, bona-fide <code>nodeList</code> object.</p>

<p><strong>Not</strong> <code>nodelist = [document.getElementById("mydiv")];</code></p>

<p>No libraries, please.</p>
 

Latest posts

Top