-
-
Save kristing40/6333f8a4d2b54797a3bb to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html> | |
<head lang="en"> | |
<meta charset="UTF-8"> | |
<title></title> | |
<style> | |
body { | |
background-color: #ccc; | |
margin: 0; | |
padding: 0; | |
} | |
#container { | |
width: 80%; | |
margin: 20px auto; | |
padding: 25px; | |
border: 1px solid #999999; | |
background: #fff; | |
} | |
.star { | |
border: 1px solid black; | |
width: 50px; | |
height: 50px; | |
margin: 10px; | |
display: inline-block; | |
} | |
.star.active { | |
background-color: yellow; | |
} | |
</style> | |
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.js"></script> | |
</head> | |
<body> | |
<div id="container"> | |
<div class="star"></div> | |
<div class="star"></div> | |
<div class="star"></div> | |
<div class="star"></div> | |
<div class="star"></div> | |
</div> | |
<script> | |
$(function(){ | |
$('#container').on('mouseover', '.star', function(){ | |
var el = $(this); | |
el.addClass('active'); | |
el.prevAll('.star').addClass('active'); | |
}) | |
}) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment