Created
January 2, 2011 01:46
-
-
Save amolbrid/762191 to your computer and use it in GitHub Desktop.
Year and month selector
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
.horizontal_list { | |
font-size: 14px; | |
width: 100%; | |
overflow: hidden; | |
} | |
.horizontal_list ul { | |
margin: 3px; | |
text-align: center; | |
float: right; | |
} | |
.horizontal_list li { | |
list-style-type: none; | |
float: left; | |
text-align: center; | |
overflow: hidden; | |
font-family: "Lucida Grande", sans-serif; | |
margin: 0px 3px; | |
border: 1px solid #ccc; | |
padding: 3px; | |
color: #292929; | |
cursor: pointer; | |
-moz-border-radius: 3px; | |
-webkit-border-radius: 3px; | |
border-radius: 3px; | |
} | |
.horizontal_list li.selected, .horizontal_list li:hover { | |
-moz-box-shadow: 0px 0px 2px #bbb; | |
-webkit-box-shadow: 0 0 2px #bbb; | |
box-shadow: 0 0 2px #bbb; | |
border: 1px solid #62605F; | |
color: #fff; | |
background-color: #827E7D; | |
} |
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
<html> | |
<head><title>Year and month selector</title></head> | |
<body> | |
<div id="years" class="horizontal_list"> | |
<ul> | |
<li>2009</li> | |
<li>2010</li> | |
<li class="selected">2011</li> | |
<li>2012</li> | |
</ul> | |
</div> | |
<div id="months" class="horizontal_list"> | |
<ul> | |
<li class="selected">Jan</li> | |
<li>Feb</li> | |
<li>Mar</li> | |
<li>Apr</li> | |
<li>May</li> | |
<li>Jun</li> | |
<li>Jul</li> | |
<li>Aug</li> | |
<li>Sep</li> | |
<li>Oct</li> | |
<li>Nov</li> | |
<li>Dec</li> | |
</ul> | |
</div> | |
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script> | |
<script type="text/javascript" src="year_month.js"></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
function onClick_MonthOrYear(event) { | |
var target = $(event.target); | |
if(target.is('li')) { | |
var selected = target.parent().find('li.selected'); | |
if(selected.text() != target.text()) { | |
selected.removeClass("selected"); | |
$(event.target).addClass("selected"); | |
} | |
} | |
} | |
$(function() { | |
$("#years").click(onClick_MonthOrYear); | |
$("#months").click(onClick_MonthOrYear); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment