Skip to content

Instantly share code, notes, and snippets.

@dgloriaweb
Created July 19, 2018 13:33
Show Gist options
  • Save dgloriaweb/b86da8448dd587545f27af102da1382c to your computer and use it in GitHub Desktop.
Save dgloriaweb/b86da8448dd587545f27af102da1382c to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/vawimirugo
<!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>
.styleClass
{
display:table-cell;
border:5px solid black;
padding: 20px;
text-align:center;
}
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