我使用jquery刪除了以下確認代碼。問題是它假定名稱列的位置。我現在在第一行有名字。而不是使用.prev('td')
,反正有沒有使用jQuery從當前行的第一列獲取值?如何在html表中使用jQuery獲取當前行中第一列的值
<script type='text/javascript'>
$(document).ready(function() {
$("a.delete").click(function(e) {
e.preventDefault();
var url = $(this).attr("href");
var name = $(this).parent().prev('td').prev('td').text();
jConfirm('Are you sure you want to delete this:' + name, 'Application Delete', function(r) {
if (r) {
window.location = url;
}
});
});
});
</script>
你可以看看http://stackoverflow.com/questions/10796559/jquery-get-first-column-value-on-fourth-row-only-of-html-table – Lijo 2012-05-29 14:29:21