概 述
lastElementChild 返回当前元素的最后一个子元素节点,如果没有子元素节点,则返回null
.该属性是只读的.
语法
var childNode = elementNodeReference.lastElementChild;
例子
<p id="para-01"> <span>First span</span> <b>bold</b> </p> <script type="text/javascript"> var p01 = document.getElementById('para-01'); alert(p01.lastElementChild.nodeName) </script>
弹出框显示 "B".
相关链接
childElementCount
children
firstElementChild
lastElementChild
nextElementSibling
previousElementSibling
规范
lastElementChild
was introduced in the W3C Element Traversal Specification.