Jquery - click button to do the listing show and button Hide?

Asked

Viewed 272 times

1

Good, I implemented a listing and I have a button where more elements appear. However, I want this button to disappear. I implemented this code, but the button does not disappear:

<script>
    $("button").click(function(){
       $("#fotos").fadeIn();
       $("#button").hide();
    });
</script>

The only thing that happens is the fadein of the photo listing with id=photos. Thank you.

  • 2

    Claudia, at first you used $("button") as an element, and in Hide $("#button") as an id. I think there’s your mistake.

1 answer

2


How @Pedro said set an id for your button:

<button id="button" ...>

or in place of id can use the this to hide the element that activated the event click:

 $("button").click(function(){
   $("#fotos").fadeIn();
   $(this).hide();
 });

Browser other questions tagged

You are not signed in. Login or sign up in order to post.