Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可能重复: href 与 onclick 中的 JavaScript 函数
从<a>, Javascript 可以通过两种方式调用:
<a>
<a href="javascript:alert('href triggered me')">Click me!!!</a>
<a href="#" onclick="alert('I was triggered by a DOM event')">Click me!!!</a>
据我所知,Web 开发人员平等对待这两种方式。两者的优点和缺点是什么?