What is the best practice of using links / <a> tags with explicit hrefs to other pages on your site (i.e. href = "/ blah / blah / blah.html) against having hrefs / divs / etc. that don’t have explicit href, and their onclick set in the finished document handler with JavaScript in the main.js.
I'm not an expert when it comes to web development, but I like to learn jQuery and the like, and I approach the concept of unobtrusive JavaScript. Although both options above do not break the “do not have JavaScript in HTML” part of this mentality, I believe that I hung up on “Separation of structure and presentation from behavior”. Although, admittedly, it was more natural for me to put a <a> tag and explicitly set href, I believe that this is really a behavior and should therefore be set in JS.
Is it really far, or am I just not used to it? The other side of me sees the advantage of putting it in JS, b / c, now I have the ability to completely control the behavior of this link without changing anything in the HTML. You'll probably say that I'm on the notorious fence. Please help me. =)
(One note: the site makes heavy use of JavaScript, so the concept of providing JS functions is disabled, it is not really a concern, since most of the site will not work without it.)
source
share