+ 1

Click on HTML body with JS

Fairly new to all things web. Can I change a js variable or call a function by having the user click anywhere on the body of the webpage?

11th Aug 2018, 4:00 AM
Nathan Lewis
Nathan Lewis - avatar
1 Odpowiedź
+ 3
yes //js window.onload = function(){ document.body.addEventListener('click', function(){ alert('you clicked on the body lol') }) } //Make sure that something is in the body.
11th Aug 2018, 4:28 AM
Nomeh Uchenna Gabriel
Nomeh Uchenna Gabriel - avatar