如何在函数中识别它是否已被锚标签 href 调用?
在这种情况下,事件为空。所以 event.target 和 event.srcElement 不起作用。
代码
HTML
<a href="SomeFunction();">Href works here</a>
JavaScript
function SomeFunction ()
{
// I need to get the anchor element that invoked this function
}