PHP群:95885625 Hbuilder+MUI群:81989597 站长QQ:634381967
    您现在的位置: 首页 > 开发编程 > Jquery教程 > 正文

    jQuery 遍历each() 方法

    作者:admin来源:B5教程网浏览:时间:2020-09-30 00:07:50我要评论
    导读:jQuery 遍历each() 方法规定为每个匹配元素规定运行的函数。语法$(selector).each(function(index,element))<html><head><meta http-equ...
    jQuery 遍历each() 方法规定为每个匹配元素规定运行的函数。
    语法
    $(selector).each(function(index,element))
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <title>B5教程网</title>
    <script type="text/javascript" src="http://www.bcty365.com/statics/js/bcty365_js/jquery.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
      $("button").click(function(){
        $("li").each(function(){
          alert($(this).text())
        });
      });
    });
    </script>
    </head>
    <body>
    <button>jQuery遍历each()函数输出每个列表项的值</button>
    <ul>
    <li>B5教程网</li>
    <li>www.bcty365.com</li>
    <li>程序信息网</li>
    </ul>
    </body>
    </html>

    转载请注明(B5教程网)原文链接:https://b5.mxunkeji.com/content-47-358-1.html
    相关热词搜索: each 遍历