Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
27
rated 0 times [  29] [ 2]  / answers: 1 / hits: 72384  / 13 Years ago, wed, october 26, 2011, 12:00:00

I know that when using jQuery you can do $('element').click(); to catch the click event of an HTML element, but how do you do that with plain Javascript?


More From » html

 Answers
35
document.getElementById('element').onclick = function(e){
alert('click');
}


DEMO: http://jsfiddle.net/e9jZW/1/


[#89437] Monday, October 24, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
elians

Total Points: 417
Total Questions: 87
Total Answers: 101

Location: Barbados
Member since Sun, Nov 27, 2022
2 Years ago
;