1 回答

TA贡献1809条经验 获得超8个赞
您可以将标识符设置为data-输入的元素:
function QuickView(element) {
var rowId = $(element).data('id');
// here comes the rest of your code.
}
$.ajax({
url: "fetchurban.php",
method: "POST",
data:{id:id},
dataType: "JSON",
success: function(data){
if (data){
var trHTML = '';
$.each(data, function (i, item) {
trHTML +='<tr><td><input type="checkbox" data-id="'+ item.TblID +'" onclick="QuickView(this)"></td><td>' + item.Type + '</td><td>' + item.Master + '</td><td>' + item.Slave + '</td><td>' + item.Orbit + '</td><td>' + item.Mode + '</td><td><a href='+ item.ImgTIF+ ' title="Download High Quality" data-toggle="tooltip"><span class="glyphicon glyphicon-download"> </span></a><a href=#?id='+ item.ImgLow + ' title="Download Low Quality" data-toggle="tooltip"><span class="glyphicon glyphicon-cloud-download"></span></a></td></tr>' ;
});
$('#ftbl tbody').append(trHTML);
}
}
})
})
这是上面的演示。
编辑:
我删除了关于不允许对 ID 属性使用整数的初始句子,因为正如 Quentin 在评论中指出的那样,它不再有效。有时很难忘记你曾经学到的东西。
添加回答
举报