Created
July 19, 2018 13:33
-
-
Save dgloriaweb/b86da8448dd587545f27af102da1382c to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/vawimirugo
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<style type="text/css"> | |
</style> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<style id="jsbin-css"> | |
.styleClass | |
{ | |
display:table-cell; | |
border:5px solid black; | |
padding: 20px; | |
text-align:center; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="styleClass" id="DIV1" >DIV1 element | |
<div class="styleClass" id="DIV2" >DIV2 element | |
<div class="styleClass" id="DIV3" >DIV3 element | |
</div> </div></div><script id="jsbin-javascript"> | |
var divElements= document.getElementsByTagName('div'); | |
for (var i =0;i<divElements.length;i++) | |
{ | |
divElements[i].onclick = function(event){ | |
event = event ||window.event; | |
event.stopPropagation(); | |
this.style.borderColor="red"; | |
alert(this.getAttribute("id")+" border color changed"); | |
} | |
} | |
</script> | |
</body> | |
</html> |
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
.styleClass | |
{ | |
display:table-cell; | |
border:5px solid black; | |
padding: 20px; | |
text-align:center; | |
} |
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
var divElements= document.getElementsByTagName('div'); | |
for (var i =0;i<divElements.length;i++) | |
{ | |
divElements[i].onclick = function(event){ | |
event = event ||window.event; | |
event.stopPropagation(); | |
this.style.borderColor="red"; | |
alert(this.getAttribute("id")+" border color changed"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment