码迷,mamicode.com
首页 > 其他好文 > 详细

jq遍历table表demo

时间:2018-05-20 21:25:50      阅读:244      评论:0      收藏:0      [点我收藏+]

标签:ext   var   index   height   遍历   cti   func   init   ati   

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script type="text/javascript" src="./jquery.min.js"></script>
    <style>
        table {
            margin: 0 auto;
        }
        .bottm {
            width: 70px;
            height: 30px;
            background-color: #447fec;
            color: #fff;
            text-align: center;
            line-height: 30px;
            margin: 0 auto;
        }
    </style>
</head>
<body>
    <table>
        <tr>
            <td class="one1">
                <input type="text">
            </td>
            <td class="one2">
                <input type="text">
            </td>
            <td class="one3">
                <input type="text">
            </td>
        </tr><tr>
            <td class="one1">
                <input type="text">
            </td>
            <td class="one2">
                <input type="text">
            </td>
            <td class="one3">
                <input type="text">
            </td>
        </tr><tr>
            <td class="one1">
                <input type="text">
            </td>
            <td class="one2">
                <input type="text">
            </td>
            <td class="one3">
                <input type="text">
            </td>
        </tr>
    </table>
    <div class="bottm">提交</div>
    <script>
    $(function () {
        $(.bottm).on(click,function () {
             $(table tr).each(function(index){//遍历所有tr元素
                var data = [
                    $(this).find(td).eq(0).find(input).val(),
                    $(this).find(td).eq(1).find(input).val(),
                    $(this).find(td).eq(2).find(input).val(),     
                    ];
                console.log(data);   
                })    
        });
       
        
    })
    
    
    </script>
</body>
</html>

 

jq遍历table表demo

标签:ext   var   index   height   遍历   cti   func   init   ati   

原文地址:https://www.cnblogs.com/xiaobiaomei/p/9064522.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!