user222
user222

Reputation: 597

jquery slideToggle with siblings not working

I would like to hide one div and show other div.

While hiding and showing other div, it should look like a slide, which can be achieved using slideToggle() in jQuery.

Please suggest the necessary changes in my javascript to make div appear as a slide when clicked on 1 or 2 to show corresponding div in the table. Please find the complete example in this fiddle.

When user clicks on 1 divOne12 should be shown and when user clicks 2 divTwo12 should appear and previous div should be hidden. How can i apply slideToggle() in the below javascript function.

Thanks.

Below is the javascript:

$(function () {
    $('.navigateTest').click(function () {
        var t = $(this).data('target');
        $('#'+t).show().siblings('div').hide();
    });
});

Upvotes: 1

Views: 360

Answers (1)

Matt Kenefick
Matt Kenefick

Reputation: 1206

Example: http://jsfiddle.net/0p7djjnc/9/

$(function () {
    $('.navigateTest').click(function () {
        var t = $(this).data('target');
        $('#'+t).slideDown(500).siblings('div').slideUp(500);
    });
});

Is this what you're referring to?

Upvotes: 1

Related Questions