Answers for "document.queryselector picks first or last"

0

document.queryselector picks first or last

var elFirst = document.querySelector(".myclass"); //first element
var elLast = document.querySelector(".myclass:last-child"); //last element

But be careful!
:last-child and :first-child are relevant to the parent element, 
not to the list! It means that there could be several first-childs 
and several last-childs
Posted by: Guest on December-23-2020

Code answers related to "document.queryselector picks first or last"

Code answers related to "Javascript"

Browse Popular Code Answers by Language