Jeroen
Jeroen

Reputation: 137

jquery show hide

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:

I have searched whole this site , and well the result is in the Fiddle

can someone help me with this

Upvotes: 0

Views: 415

Answers (1)

Alex
Alex

Reputation: 6406

So you want to hide all .news except the first one?

http://jsfiddle.net/R4ng5/13/

$(".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

Related Questions