Skip to content

Instantly share code, notes, and snippets.

@kristing40
Forked from anonymous/stars.html
Created July 24, 2014 02:21
Show Gist options
  • Save kristing40/6333f8a4d2b54797a3bb to your computer and use it in GitHub Desktop.
Save kristing40/6333f8a4d2b54797a3bb to your computer and use it in GitHub Desktop.
<!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