Jquery - click button to do list show and button hide?

1

Well, I've implemented a listing and I have a button where clicking on it adds more elements. However I want this button to disappear later. 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 listing of photos with id = photos. Thank you.

    
asked by anonymous 09.05.2016 / 16:29

1 answer

2

As @Pedro said, set an id for your button:

<button id="button" ...>

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

 $("button").click(function(){
   $("#fotos").fadeIn();
   $(this).hide();
 });
    
09.05.2016 / 16:39