Get first
  • WITHOUT jquery
  • 后端 未结 7 1154
    爱一瞬间的悲伤
    爱一瞬间的悲伤 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:51

      document
          .getElementsByTagName("ul")[0]
          .getElementsByTagName("li")[0]
          .style.color = "blue";
      

    提交回复
    热议问题