Selecting a last child in javascript

后端 未结 5 582
不知归路
不知归路 2020-12-21 01:39

I have a handle on an Un-ordered List (for my example i will call the handle Var1) and would like to be able to assign its last li to a variable. I tried Lastli = var

5条回答
  •  心在旅途
    2020-12-21 02:06

    either ulReference.children[ulReference.children.length -1] or ulReference.childNodes[ulReference.childNodes.length -1]. The difference between the two can be found here

提交回复
热议问题