click() action on ‘hidden button’ with javascript causes page reload

[ad_1]

Hi,

I’m using your button shortcode to give points for downloads or video views. I setup it with specific classes like ‘deck-download’ or ‘ps23-video-1’ then I trigger those with javascript function with might be attached to different elements on the page using this
document.querySelector('.deck-download').click();

or for videos:

document.querySelectorAll('.ps23-video').forEach((video, index) => video.onplay = function(){
pageVideosPlayed[index] ?  console.log(video ${index} played already) :  document.querySelector(.ps23-video-${index}).click(); 
  })
})

This approach seemed to work perfectly fine till now… when above causes instant page reload when any video is played.

Any suggestions?

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer