WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

JavaScript HTML DOM Node List


A hub list is an accumulation of nodes


HTML DOM Node List

The getElementsByTagName() strategy restores a node list. A hub list is an exhibit like gathering of nodes.

The following code chooses all <p> hubs in a document:

Example

var x = document.getElementsByTagName("p");

The hubs can be gotten to by a file number. To get to the second <p> hub you can write:

y = x[1];
Try it Yourself »

Note: The record begins at 0.


HTML DOM Node List Length

The length property characterizes the quantity of hubs in a hub list:

Example

var myNodelist = document.getElementsByTagName("p");
document.getElementById("demo").innerHTML = myNodelist.length;
Try it Yourself »

Example explained:

  1. Get all <p> components in a hub list
  2. Display the length of the hub list

The length property is helpful when you need to circle through the hubs in a hub list:

Example

Change the foundation shade of all <p> components in a hub list:

Try it Yourself »