stevenjin 2023-02-27 15:17 采纳率: 95.5%
浏览 34
已结题

用jqeury获取选中table表格中单元格的内容

用jqeury获取选中选项卡table表格中单元格的内容
想到了如下 代码,但不能遍历整个表格,望指正,谢谢!

    $("div.tab-pane.active").each(function () {    
            debugger
            var tdArr = $(this).children();
            var Name = tdArr.eq(0).find('input').val();          
            });  

<div id="Level" class="container tab-pane active" style="margin:2px; font-size:20px;">
                    <table class="table table-striped">
                        <tbody>
                            <tr>
                                <td>
                                </td>
                            </tr>
                            <tr>
                                <td style="font-size:20px;color:#008A7D">Name</td>
                                <td>
                                    <input type="text" value="pH" class="form-control input-group input-group-lg" data-ajax-success="afterSuccess" data-ajax="true" style="font-size:20px;" id="DisplayName" name="DisplayName" />
                                    <input type="hidden" value="0" id="InDepth" name="InDepth" />
                                </td>
                            </tr>
                            <tr>
                                <td style="font-size:20px;color:#008A7D">Unit</td>
                                <td><input type="text" value="" class="form-control input-group input-group-lg" style="font-size:20px;" id="Unit" name="Unit" /></td>
                            </tr>
                            <tr>
                                <td style="font-size:20px;color:#008A7D">Screen Priority[0,65]</td>
                                <td><input type="text" value="10" class="form-control input-group input-group-lg" style="font-size:20px;" id="Unit" name="Unit" /></td>
                            </tr>
                            <tr>
                                <td style="font-size:20px;color:#008A7D">Decimals[0,4]</td>
                                <td><input type="button" value="2" class="form-control input-group input-group-lg" style="font-size:20px;" /></td>
                            </tr>
                            <tr>
                                <td><input type="submit" value="Confirm" class="form-control btn-primary" style="font-size:20px;" /></td>
                                <td><input type="reset" value="Cancel" class="form-control btn-secondary" style="font-size:20px;" /></td>
                            </tr>
                        </tbody>
                    </table>
                </div>                

展开全部

  • 写回答

1条回答 默认 最新

  • 简效 2023-02-28 01:36
    关注
    
     $("div.tab-pane.active table input").each(function (i,v) {    
                var Name = $(i).val();
                console.log(Name)
                });  
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录
编辑
预览

报告相同问题?

问题事件

  • 系统已结题 4月6日
  • 已采纳回答 3月30日
  • 创建了问题 2月27日