Reputation: 137
i try to show and hide divs on click but something isnt going wel
can someone have a look at this
what i want is:
when people arrive on the page they see the content of the first "news" div
when clicking on a other anchor they will see the corresponding content instead of the previous
append a style to the active anchor link
I have searched whole this site , and well the result is in the Fiddle
can someone help me with this
Upvotes: 0
Views: 415
Reputation: 6406
So you want to hide all .news
except the first one?
$(".news:not(:first)").hide();
And if you want to style the active link: http://jsfiddle.net/R4ng5/14/
$(list).children('li:first').children('a').addClass('active');
$('#sidebar a').click(function() {
var i = $('#sidebar a').index($(this));
$('.news').hide();
$(".news:eq(" + i + ")").show();
$('#sidebar a').removeClass('active');
$(this).addClass('active');
});
Upvotes: 3