我有一个相当直接的问题。为什么在我的点击功能中不能使用$('a.view').attr('id')
(代码中的Ref // 1)?我试过了,但它失败了,但this.id
的作品。我想我主要是想知道在下面的代码的情况下的区别:在点击功能中获取ID通过href链接
displayRecord.php(以下链接调用点击功能):
echo '<td><a href="#" style="text-decoration: none;" id="'.$data['id'].'" class="view" ><input type="button" value="View" /></a></td>';
editTicket.php:
$('a.view').click(
function(e)
{
//1
var ticket_id = this.id;
dlg.load('displayRecord.php?id='+this.id, function(){
var escalationValue = '';
$.post('escalateValue.php',{post_ticket_id:ticket_id},
function(data) {
if (data == 'No'){
showCount();
}
});
dlg.dialog('open');
});
});