Answer by Headshota for how to not use inline js events?
The main idea here is that the DOM element that you want to register the handler on should be loaded. so either you do the event binding after the element html, or you could do it in the window.onload...
View ArticleAnswer by Quentin for how to not use inline js events?
The prefered method is to use addEventListener, often in combination with a library (such as YUI or jQuery) that smooths over variations between browsers (e.g. old-IE not supporting...
View ArticleAnswer by aaaidan for how to not use inline js events?
Yes, that is one valid way to add an event to an object, but it prevents more than one function from being bound at a time.I would recommend looking into jQuery (or similar javascript library, like...
View ArticleAnswer by Manse for how to not use inline js events?
The cleanest way to add event listeners is to use the built in methods :var el = document.getElementById('mydiv');if (el.addEventListener) { el.addEventListener('click', modifyText, false); } else if...
View Articlehow to not use inline js events?
I am used to using inline events in my websites for example<head><script>function func() {alert("test");}</script></head><body><div id="mydiv"...
View Article