zoukankan      html  css  js  c++  java
  • Jquery获取鼠标所在行Index

    页面结构:

    <table id="tb_ConfModerator" class="table table-hover">
        <thead>
            <th>姓名</th>
            <th>邮箱</th>
            <th>操作</th>
        </thead>
        <tbody>
            <tr>
                <td><input type="text" name="txtName"/></td>
            </tr>
            <tr>
                <td>346425158@qq.com</td>
            </tr>
            <tr>
               <td>
                  <div style="display:none"><input type='button' value='删除' onclick="clickbutton(this)"/>
                  </div>
                </td>
            </tr>
        </tbody>
    </table> 

    鼠标悬浮事件:

    $("#tbScheduled td").mouseover(function () {
        //获取鼠标所在列表行数
        var trSeq = $(this).parent().parent().parent().find("tr").index($(this).parent()[0]);
        //操作层显示
        $('#tbScheduled').find('tr:eq(' + (trSeq) + ')').find('td:eq(2) div').css("display", "block");
    });
    
    $("#tbScheduled td").mouseout(function () {
            var trSeq = $(this).parent().parent().parent().find("tr").index($(this).parent()[0]);
            $('#tbScheduled').find('tr:eq(' + (trSeq) + ')').find('td:eq(2) div').css("display", "none");
    });

    获取删除按钮所在行其他列的值:

    var clickbutton=function(obj){
        var trSeq = $(obj).parent().parent().parent().find("tr").index($(obj).parent().parent()[0]);
        var name = $('#tb_ConfModerator tbody').find('tr:eq(' + (trSeq) + ')').find($("input[name='txtName']")).val();
        var email= $('#tb_ConfModerator tbody').find('tr:eq(' + (trSeq) + ')').find('td:eq(1)').text();
    }
  • 相关阅读:
    软件测试常见概念
    Apollo简介及工作原理
    bug的编写技巧与级别划分
    native与H5优缺点及H5测试
    优惠券测试
    go语言-for循环
    go语言-流程控制--if
    go语言-二进制与位运算
    cookie和session
    AJAX
  • 原文地址:https://www.cnblogs.com/dreamshallow/p/3407988.html
Copyright © 2011-2022 走看看