CSS
-Tricks
treehouse :
what would you like to learn today?
Web Design
Web Development
iOS Development
Show search box
Search
Search in:
All
Articles
Forums
Snippets
Videos
✕
Home
Forums
Snippets
Gallery
Videos
Almanac
Demos
Lodge
Navigation 'n' Search
Forums
Illustration by Nick Sirotich
Forums
»
JavaScript Jungle
jQuery list
Makeshift
Permalink to comment
#
December 2009
I have thought about eliminating anchors from my site menu. I have tested it and it works fine.
$(\"#nav ul li\").click(function(){
window.location = $(this).attr(\"class\");
});
and the HTML would be
<li class="somepage.html">Some page</li>
and it would link to somepage.html
would this be bad practice?
and what would the cons be? (other than someone disabling their javascript and links being unclickable)
cybershot
Permalink to comment
#
December 2009
I don't know, but I am curios as to what the purpose of the code is. What does it do?
Hawke
Permalink to comment
#
December 2009
I think it's bad practice. A class atrribute is suppose to store class infromation, certainly not an anchor. Plus, why would you want to remove the need of anchor tag ? They're here for a reason, use them :)
Add a Comment
$(\"#nav ul li\").click(function(){
window.location = $(this).attr(\"class\");
});
and the HTML would be
<li class="somepage.html">Some page</li>
and it would link to somepage.html
would this be bad practice?
and what would the cons be? (other than someone disabling their javascript and links being unclickable)