admin管理员组文章数量:1287632
Making a link with
javascript:void(0)
violate the W3C standard.
I need to have a
<a href="">
in my code that is not clickable and pass the W3C norms. Please don't tell me to just remove the a link because I need it for my menu and the class is important.
How could I make a link that goes nowhere and it's W3C friendly ?
Making a link with
javascript:void(0)
violate the W3C standard.
I need to have a
<a href="">
in my code that is not clickable and pass the W3C norms. Please don't tell me to just remove the a link because I need it for my menu and the class is important.
How could I make a link that goes nowhere and it's W3C friendly ?
Share Improve this question asked Dec 21, 2011 at 15:39 WarfaceWarface 5,11910 gold badges58 silver badges83 bronze badges3 Answers
Reset to default 13Just use this onclick event, which does exactly the same as void(0)
<a href="#" onclick="return false;">Something</a>
So long as there's not any scrolling on your page, why not
<a href="#" id="yourDeadA">
document.getElementById("yourDeadA").addEventListener("click", function() {
//run your code
return false;
});
This should work fine :
<a href="#"></a>
本文标签: hyperlinkjavascriptvoid(0) not accepted by W3Chow to resolve thisStack Overflow
版权声明:本文标题:hyperlink - javascript:void(0) not accepted by W3C, how to resolve this? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741257827a2367026.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论