Quick Question.
Should we put Javascript in the HREF or use onClick (event)?
Are there any pros/cons to using either one. Personally I think it\'s easier/cle
I would personally not put the JavaScript code in the HTML. You should use an event listener that will get triggered when the is clicked on.
Click Me
And then:
document.getElementById('linkA').addEventListener('click', function(e){
e.preventDefault(); // Prevents page from scrolling to the top
alert('foo!');
});