我的网页上有一张桌子。我最近将其从HTML表格更改为CSS表格。我有一个上下文菜单,显示在我的表的每一行。上下文菜单正在处理HTML表,而不是CSS表。
HTML:( CSS表的示例)
<div class="tbody">
<div class="td"><%= products[i].productOwner %></div>
<div class="td"><%= products[i].engineeringOwner %></div>
<div class="td"><%= products[i].engineeringLead %></div>
...
#contextMenu:
<ul id="contextMenu">
<li><a href="edit" onclick="location.href=this.href+'?id=' + recordID; return false;">Edit</a></li>
<li><a onclick="Confirm.render('Delete', 'Are you sure you want to delete this record?', recordID);">Delete</a></li>
</ul>
jQuery的:
$(document).bind('contextmenu', function (e) {
e.preventDefault();
e.stopPropagation();
recordID = $(e.target).parent().attr('id');
if ($(e.target).hasClass('td')) {
$('#contextMenu').css({
left: e.pageX + 'px',
top: e.pageY + 'px'
}).show().fadeIn(500, startFocusOut());
}
return false;
});
我已调试并确认$(e.target)
确实有td
类,因此应输入if
语句