用php和javascript可以做到这一点吗?我可以回显我的锚标记ID并使用jquery onclick事件检索它吗?回显“a href = 'example.con‘id=’”.$ row‘’userid‘.“’示例/a‘;现在在jquery/javascript中,我说了一些类似单击锚标记的话,我得到了行的id。如果没有人能给我另一个解决方案。
发布于 2014-02-12 20:36:54
这应该能做你想要的:
$('#myLinkId').click(function() {
var linkId;
linkId = $(this).prop('id');
alert(linkId);
});这段代码:.prop('id');是获取链接ID的具体内容。
发布于 2014-02-12 21:07:35
非jQuery替代方案:
function getId(e){
//IE e.srcElement.href);
//Other e.target.href);
alert(e.srcElement.id);
}将onclick=“getId(事件)”添加到锚上。
对于跨浏览器实现,您可以看到以下问题:
How can I make event.srcElement work in Firefox and what does it mean?
https://stackoverflow.com/questions/21738957
复制相似问题