firstChild

    <div class="box1">he
        <div class="box2">盒子2</div>
    </div>

$('.box1').children[0].nodeName //div: 忽略空白节点,只选择element元素节点,而且兼容IE678

$('.box1').firstChild.nodeName //#text

$('.box1').childNodes[0].nodeName //#text

$('.box1').firstElementChild.nodeName //div----但是不兼容IE678

原文地址:https://www.cnblogs.com/huangxingyuan/p/6535920.html