EDIT: solved: IDs can't start with a digit.
I made a div with tabs above it (2009 - 2013). In the div where the content should show up, I wrote just the year to indicate if my code works.
If I write $('div#updates div.content div').hide();
, all the content hides (just as it should), but if I write $('div#updates div.content div#2009').show();
, nothing happens. Does anyone know why (I supposed wrong selector, but I checked that and it didn't work.
HTML:
<div id="updates">
<div class="tabs">
<div id="2009">2009</div>
<div id="2010">2010</div>
<div id="2011">2011</div>
<div id="2012">2012</div>
<div id="2013">2013</div>
</div><br />
<div class="content">
<div id="2009">
2009
</div>
<div id="2010">
2010
</div>
<div id="2011">
2011
</div>
<div id="2012">
2012
</div>
<div id="2013" class="active">
2013
</div>
</div>
JS (jQuery):
$(document).ready(function(e) {
$('div#updates div.tabs div#2013').addClass("active");
$('div#updates div.tabs div').click(function(e) {
$('div#updates div.tabs div').removeClass("active");
$(this).addClass("active");
$('div#updates div.content div').hide();
});
$('div#updates div.tabs div#2009').click(function(e) {
$('div#updates div.content div#2009').show();
});
$('div#updates div.tabs div#2010').click(function(e) {
$('div#updates div.content div#2010').show();
});
$('div#updates div.tabs div#2011').click(function(e) {
$('div#updates div.content div#2011').show();
});
$('div#updates div.tabs div#2012').click(function(e) {
$('div#updates div.content div#2012').show();
});
$('div#updates div.tabs div#2013').click(function(e) {
$('div#updates div.content div#2013').show();
});
});
css:
div#updates div.tabs div{
float: left;
padding: 5px 10px 4px 10px;
background-color: #a90000;
border: 1px solid #600;
z-index: inherit;
position: relative;
margin-right: -1px;
cursor: default;
}
div#updates div.tabs div.active{
background-color: #f00;
border-bottom: none;
padding-bottom: 5px;
z-index: 10;
}
div#updates div.content{
background-color: #f00;
position: absolute;
top: 38px;
width:500px;
border: 1px solid #600;
padding: 10px;
z-index: 9;
}
div#updates div.content div{
display: none;
}
div#updates div.content div.active{
display: block;
}
/*opmaak berichten*/
div#updates div.content div h3{
color: #0f0;
font: 24px Impact , sans-serif;
text-decoration: none;
}