说我有一个链接:
<a href="http://www.example.com">Example!</a>
我想保持链接完整,但我想要一个 onclick 事件来决定链接是否可点击
<a onclick='stopLight()' href="http://www.example.com">Example!</a>
function stopLight() {
// conditional logic
// return true or return false
}
因此,如果 stopLight() == true,则链接有效,如果 stopLight() == false,则链接无效。在不改变href的情况下使这成为可能,因为我宁愿不