first()

作者: 知识分享share | 来源:发表于2018-04-04 23:53 被阅读0次
    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <meta http-equiv="X-UA-Compatible" content="ie=edge">
      <script src="http://code.jquery.com/jquery-1.11.3.js"></script>
      <title>Document</title>
    </head>
    <body>
    
      <div>你好</div>
      <div>好吧啊</div>
      <div>真的吗</div>
    
    </body>
    </html>
    
    <script type="text/javascript">
          var div = document.getElementsByTagName('div');
          var $div = $(div);
          var $first = $div.first();
          $first.css('color','red');
    </script>
    

    相关文章

      网友评论

          本文标题:first()

          本文链接:https://www.haomeiwen.com/subject/wotrhftx.html