How to make onclick
without jQuery, with no extra code in HTML, such as:
<a href="#" onclick="tramtramtram">
Just using an external js file?
<script type="text/javascript" src="functions.js"></script>
I need to replace this code:
$("a.scroll-up, a.scroll-down").click(function(){
SNavigate($(this).attr("href").substr(7));return false;
});
When this anchor will contain only one function to handle on click, than you can just write
otherwise, you have to use DOM method addEventListener
also remember to call the above code when all elements are loaded (eg. on window.onload)
-- edit
I see you added some details. If you want to replace the code below
with sth that doesn't use jQuery, this should do the job
W3C suggests:
Microsoft uses:
You can do some feature detection and determine which call to use.
From http://www.quirksmode.org/js/events_advanced.html.
how about this :