简体   繁体   English

通过单击相应行上的按钮来获取特定的表行值

[英]Get specific table row values by clicking a button on the respective row

Check In             Check Out            Duration  
6/7/2013 3:24:40 PM  6/7/2013 3:26:21 PM  00:01:41:000  View button
6/7/2013 3:32:25 PM  6/7/2013 3:34:26 PM  00:02:01:000  View button

On Clicking the View Details button , I m getting the table values using Jquery but i cant retrieve it very time in web. 在单击“查看详细信息”按钮时,我正在使用Jquery获取表值,但是我无法在Web上很长时间检索到它。 How to Efficiently get the table details on button click 如何在单击按钮时有效获取表详细信息

My Code is 我的代码是

for (var post in result) 
{   
    $("#tablegrid > tbody").append("<tr id=subtablegrid><td>"+result[post].CheckedIn+"</td><td>"+result[post].CheckedOut+"</td><td>"+result[post].Duration+"</td><td class='mapview'><a id="+viewbtnid+','+fieldstaffid+" href='#' data-role='button' >View Details</a></td></tr>");
    viewbtnid++;
}

$(document).on('click','.mapview a',function(){

    var id=$(this).attr('id');
    var idArr=new Array();
    idArr=id.split(",");
    alert(idArr[0]+" "+idArr[1]);
    var fieldstaffid=idArr[1];

    var fromDate=$("#tablegrid tbody tr:nth-child("+idArr[0]+") td:nth-child(1)").text();
    var toDate=$("#tablegrid tbody tr:nth-child("+idArr[0]+") td:nth-child(2)").text();
    fromDateTime=fromDate.substring(0,13);
    toDateTime=toDate.substring(0,13);
    alert(" to date "+toDateTime);
    alert(fromDateTime+" "+toDateTime);

});

please check Click here to see Demo 请检查单击此处查看演示

$(document).ready(function(){
  $('table tr').click(function(){
     alert($(this).index() + 1 );
  });
});

using that you can get index of row 使用它可以获得行的索引

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM