stevenjin 2023-02-27 23:17 采纳率: 98.2%
浏览 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 09:36
    关注
    
     $("div.tab-pane.active table input").each(function (i,v) {    
                var Name = $(i).val();
                console.log(Name)
                });  
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录

报告相同问题?

问题事件

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

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分