Created
September 20, 2013 10:46
-
-
Save prasadshir/6635827 to your computer and use it in GitHub Desktop.
Javascript Add Events Listener
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
window.onload = function(e){ | |
document.getElementById("btn1").addEventListener('dblclick', myAlert); | |
var li = document.getElementsByTagName("li") | |
for (i=1;i<li.length; i++){ | |
li[i].addEventListener('mouseover', function(e){ | |
console.log('Hey, you were here!'); | |
console.log(e); | |
}); | |
} | |
} | |
function myAlert(e){ | |
alert('Hey, you clicked!'); | |
console.log(e); | |
} |
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
<html> | |
<head> | |
<title>JS Function Examples</title> | |
<script src="binding.js" type="text/javascript"></script> | |
</head> | |
<body> | |
<h1>JS Funciton Examples</h1> | |
<ul id="myList"> | |
<li>Item 1</li> | |
<li>Item 2</li> | |
<li>Item 3</li> | |
</ul> | |
<p>This file contains JS examples | |
<button id="btn1">Click Me!</button> | |
</p> | |
<p>This is another para</p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment