[英]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
在單擊“查看詳細信息”按鈕時,我正在使用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);
});
請檢查單擊此處查看演示
$(document).ready(function(){
$('table tr').click(function(){
alert($(this).index() + 1 );
});
});
使用它可以獲得行的索引
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.