Saqib Ishfaq13,911 Points
what's the difference between these two? using TagName and QuerySel..
at 5:50 of the video teacher created this
const ulList = divList.querySelector(ul);
but i used this >>(code below) and works exactly the same! but just wondering shudnt it just remove the 1st item on the 'ul' as  , on been the 1st index position. when i click the remove button.
const ulList = document.getElementsByTagName('ul');
Ari Misha19,217 Points
Hiya there! There is a subtle difference between both methods. The querySelector() gives you the first element it encounters from the given element or id or class. Say if you've two divs with same class name, querySelector() will get you the first div.
On the other hand, getElementsByTagName() will give you an access to an array of elements even if there is a single element on the page. And its only takes tag name or element.