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

Question

I am creating a custom wordpress theme and i am little stuck in one situation, Actually i added a download link button and add some javascipt on it. The button on all posts showing and downloading fine, but according to the javascript,the (shortcode button/downlaod link button) is only clicked 2 times, after 2 times it atomatically disappers…..
The javascript code is working fine only for very first post. for other posts it does not work.

here below is my code:-

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
            <script>
               $(document).ready(function(){
                  var i = 0
                     $(".gotocls").click(function(){
                         i++
                            if(i == 2)
                             document.getElementsByClassName('gotocls')[0].style.display = 'none';
                    
                    });
            ``  });
     
         </script>  

          <a class="dkpdf-button gotocls" href="www.downloadlink.com"  target="_blank"><span class="dkpdf-button-icon"><i class="fa fa-file-pdf-o"></i></span> <?php echo $pdfbutton_text;?></a>
0
, , , , Almight Hacker 2 years 2020-09-01T06:10:24-05:00 0 Answers 58 views 0

Leave an answer

Browse
Browse