使用以下代码:
<head>
<script type="text/javascript">
function popupMsg(msg) {
alert(msg);
}
</script>
</head>
<body>
<a href="http://www.xyz.com" onClick="popupMsg('This is pop up message')">xyz.com</a>
</body>
如何在锚标签内onClick
替换?addEventListener
可以在不分配ID
锚标记的情况下完成吗?
大概是这样的:
<a href="http://www.xyz.com" something.addEventListener('click',popupMsg(SomeMsg),false)>xyz.com</a>