html 电子邮件 -
下面的内容看起来不错,但是当我在 gmail 中测试它时,它会打开链接两次(在 2 个新选项卡中),就好像发生了某种奇怪的事件冒泡......
<a href="some_url"> <button>Approve</button> </a>
我错过了一些明显的东西吗?
The following looks fine but when i test it in gmail, it opens the link twice (in 2 new tabs), it's as if there's some kind of wierd event bubbling happening....
<a href="some_url"> <button>Approve</button> </a>
am i missing something obvious?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
链接不能包含按钮。使用按钮或将链接设置为按钮样式(即看起来像按钮)。
也就是说:事件冒泡可能正在发生,因为按钮完成了它的工作,然后链接也处理了鼠标单击事件。
A link can't contain a button. Either use a button or style the link like a button (i.e. that it looks like a button).
That said: The event bubbling is probably happening because the button does it's job and then, the link processes the mouse click event, too.
显而易见的是,[X]HTML 的格式不正确。
不应包含
The obvious thing is that this is not properly formatted [X]HTML.
An
<a>
should not include a<button>
有些浏览器甚至不允许单击链接。
改为设置 href 的样式
There are browsers that will not even allow the link to be clicked.
Style the href instead