Get first
  • WITHOUT jquery
  • 后端 未结 7 1120
    爱一瞬间的悲伤
    爱一瞬间的悲伤 2020-12-19 08:13

    This may have been asked, but scrolling through about 40+ search results reveals only the jQuery solution. Let\'s say I want to get the first item in an unordered list and a

    7条回答
    •  借酒劲吻你
      2020-12-19 08:54

      Since the only valid child of

        is
      • , you can do this:

        var firstLI = document.getElementsByTagName('ul')[0].children[0];
        

    提交回复
    热议问题