racemike
racemike

Reputation: 13

Show/hide effect

I have a little blog with some social buttons for sharing that are integrated into my theme.

Now I want to change show/hide so that it is shown by default and hidden when clicked.

$(document).ready(function() {
    $(".post-share").hide();
    $("a.share-btn").click(function() {
        $(this).prev(".post-share").slideToggle("slow");
    });
});

Can anyone help?

Upvotes: 0

Views: 184

Answers (3)

Shyju
Shyju

Reputation: 218832

change the hide to show in dom ready

 $(document).ready(function() {
    $(".post-share").show();
    $("a.share-btn").click(function() {
       $(this).prev(".post-share").slideToggle("slow");
    });

 });

Upvotes: 1

Fluidbyte
Fluidbyte

Reputation: 5210

If you want it to show by default and then hide when clicked...

$(document).ready(function() {
    $(".post-share").show();
    $("a.share-btn").click(function() {
        $(this).prev(".post-share").slideUp("slow");
    });
});

Upvotes: 1

Thomas Langston
Thomas Langston

Reputation: 3735

$(document).ready(function() {
  $(".post-share").show();
  $("a.share-btn").click(function() {
    $(this).prev(".post-share").slideToggle("slow");
  });
});

Upvotes: 2

Related Questions