What is DOM(Document Object model)? We are discussing the methods ,without methods our dom will not work.
Tree representation of Html elements, Suraj kumar Jha, he is mentor in chaicode, discussed , what do I think?
It is a API(Application programming interface) for communicating with Html documents. Dom is client-side programming language, it creates a tree structure of html elements.
Selecting Document Elements
In client side javascript , we often need to modify one or more elements within our website. We have document object, we need to select the particular element from the web page, we select the elements with css selectors.
querySelector()
mdn states that the query selector returns the first element which matches within the css selector.
syntax:
querySelectorAll()
This method returns the node list which is list of documents within page. You know that array is similar to Pill strip of fungal infection, and also contain the length property, index starts from 0, NodeList are iterable , they allow you to use for/of and you can also able to use the tradition for loop also.
Pass NodeList to Array.form() method , and you will get a true array.
** getElementsByClassName **
1-It will return all the elements which have class name for ex- "masterji"
2- It returns group/ collection of html elements, which is also known as HTMLCollection.
Difference between the NodeList and HtmlCollection







Top comments (0)