📌  相关文章
📜  document.queryselector 选择第一个或最后一个 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:14.940000             🧑  作者: Mango

代码示例1
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