This code gives errors in the W3 Validator, however it does the job on click.
<span href="#" class="click">+</span>
If I convert it to the code below it validates in the W3 but on click the pointer moves up, on the screen. It does not stay on the "+"
<a href="#" class="click">+</a>
What is wrong with it?
答案 0 :(得分:3)
如果您不想提供链接,请使用<button>
代替<a>
!
<button>
元素正是您想要的,因为<a>
标记用于链接,而href="#"
会触发跳转到顶部。
答案 1 :(得分:2)
要避免在锚标记上点击跳转,请删除哈希并添加javascript:;
,如下所示:
<a href="javascript:;" class="click">+</a>
答案 2 :(得分:0)