Created
July 17, 2017 23:35
-
-
Save twalk4821/9695e1257191f85583d5227365c8728f to your computer and use it in GitHub Desktop.
QgRKQy
This file contains hidden or 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
<div class="row"> | |
<div class="box" id="box1"></div> | |
<div class="box" id="box2"></div> | |
</div> | |
<div class="row"> | |
<div class="box" id="box3"></div> | |
<div class="box" id="box4"></div> | |
</div> | |
This file contains hidden or 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 boxes = document.querySelectorAll('.box'); | |
for (box of boxes) { | |
box.addEventListener('mouseenter', function (e) { | |
e.target.classList.add('active'); | |
}); | |
box.addEventListener('mouseleave', function (e) { | |
e.target.classList.remove('active'); | |
}); | |
} |
This file contains hidden or 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
.box { | |
width:50px; | |
height: 50px; | |
margin: 5px; | |
} | |
.row { | |
display: flex; | |
} | |
#box1 { | |
background-color:red; | |
} | |
#box2 { | |
background-color:red; | |
} | |
#box3 { | |
background-color:green; | |
} | |
#box4 { | |
background-color:green; | |
} | |
.active { | |
background-color:blue!important; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment