
<div id="abc"><span>DIV的子对象</span></div>
<script language="javascript">
alert(document.getElementById('abc').firstChild.tagname) // 返回SPAN
alert(document.getElementById('abc').firstChild.innerHTML) // 返回"DIV的子对象"
</script>
和firstChild对应的还有lastChild,是对最后一个子对象的引用.
:first-child和:last-child用来选择某个元素的第一个子元素。
//输入ul li:first-child
//输入ul li:last-child
刚刚有个这方面的视频,视频的系列名称叫做 《Buid New World》 里面的第八集是讲CSS3 选择器的,有机会看看吧
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)