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
单击“查看详细信息”按钮,我使用Jquery获取表值,但我无法在Web中检索它。 如何在点击按钮时有效地获取表格详细信息
我的代码是
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);
});
答案 0 :(得分:0)
$(document).ready(function(){
$('table tr').click(function(){
alert($(this).index() + 1 );
});
});
使用它你可以得到行的索引