Created
February 18, 2017 10:52
-
-
Save zashishz/c46a5222fb644b15ad7240b0d2fe9db1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Event Names | |
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
HANDLING EVENTS | |
Method 1. | |
------------- | |
<button onclick="alert('Hello, World');">Some JS</button> | |
Method 2. | |
------------- | |
element.event = function(){ | |
//...Event Handler Code | |
//... | |
}; | |
Example: window.onload, fieldName.onblur, myElement.onclick ..etc. | |
Method 3. | |
------------- | |
myElement.addEventListener('click', myFunction, false); | |
Example: | |
div.addEventListener('onclick', function(event){ | |
}); | |
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
<<ONLOAD EVENT>> | |
window.onload(function(){ | |
//add any call you need to be executed once page loads. | |
}); | |
<<TIMER EVENT>> | |
-------------------------------------- | |
1. Timeout to trigger few seconds later | |
==> setTimeout(fnName, 1000); | |
2. setInterval to trigger every few seconds | |
==> var intervalName = setInterval(fnName, 1000); | |
3. clearInterval to clear any setIntervals | |
==> clearInterval(intervalName); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment