我尝试过以下方法:
<a href="#" class='aclass'>Fires an event</a> //pops back up to page, not nice
<a href="" class='aclass'>Fires an event</a> //refreshes the page, not nice
<a type="button" class='aclass'>Fires an event</a> //does nothing but the event, good!
Run Code Online (Sandbox Code Playgroud)
只是想知道将带有值按钮的类型属性添加到锚标记在语义上是否可以接受,因为我不记得曾经这样做过,但也许它现在发生并且实际上起作用了。
你想要的不是一个链接而是一个按钮。所以你应该使用
<button type="button" class="aclass">Fires an event</button>
Run Code Online (Sandbox Code Playgroud)
样式设置只是 CSS 的问题。
| 归档时间: |
|
| 查看次数: |
7748 次 |
| 最近记录: |