44 ms·
document.getElementById('something').addEventListener('click',function() {}) works on all browsers these days. But we're stuck in our habits. I don't deny tha
by untog 12y ago
document.getElementById('something').addEventListener('click',function() {})
works on all browsers these days. But we're stuck in our habits.
I don't deny that web development is kind of crappy, but it's just in the nature of it - the reason why iOS and Android are easier to develop for is because there's really only one client for them. Personally, I'll take the multiple, open client approach over the closed one any day, warts and all.
- bshimmin 12y agoOne key difference is the jQuery version will gracefully do nothing if "#something" doesn't exist, while yours will throw "TypeError: Cannot read property 'addEventListener' of null".