Shortcode button dosent work for all posts. Work for first post only

Okay,

So I had asked you few things in comments for your question, you are yet to answer them, But I shall begin with some things.

So I assume that

1.) for 10 posts, each post has 1 download link unique to it,

2.) each link has the class ‘gotocls’

3.) Downloading stuff is working correctly, meaning I just need to get it to hide/show when necessary.
4.) each of the 10 download links have at least 1 class common, from your code it seems that the common class is 'gotocls'

So I pointed out that it does not make sense to use ‘[0]‘ in your code for getting the element. You pointed out that it works perfectly for the first download link, that is because you are only targeting the first link with [0], I have not tested, but I think, you can get to the 2nd Link, using ‘[1]’ because that’s how it works.

HTML should look like this.

<a class="gotocls" data-click="0">0</a>
<a class="gotocls" data-click="0">0</a>
<a class="gotocls" data-click="0">0</a>
<a class="gotocls" data-click="0">0</a>
<a class="gotocls" data-click="0">0</a>
<a class="gotocls" data-click="0">0</a>

**Please not that the data-click=”0″ attribute is really necessary for code to work, so please add it to your html. **

In case due to some limitations you cannot put the data attribute then please use this JS, but I do not recommend JS for adding data-attributed on page load, as html seems to be much more logical and efficient thing to do

$(document).ready(function() {

$('.gotocls').each(function() {
     $(this).attr('data-click', '0');
});
});

And your code doesn’t work when trying all the 10 link clicks. So, based on the inputs and based on lack of HTML, below is my approach, please try it and let me know in comments to my answer, I think this one should work.

 $(document).ready(function(){
   $(".gotocls").click(function() {
     count= $(this).attr("data-click");
     count ++;
       if(count==5){
                $(this).hide();
       }
       else{
            $(this).attr('data-click', count);
       }
   });
  });