Home > other >  How can i target the embed video in wordpress elementor?
How can i target the embed video in wordpress elementor?

Time:12-31

I need to add custom javascript to wordpress by targeting the id of the embedded video I attach an example (https://graziafassari.com/vsl/). I have made a script (which target the video by an id and have some logic on behalf of video duration) which is working fine in local HTML so by thinking same I assign the id in elementor but it's not working. so how can i achieve this in WordPress?

CodePudding user response:

You can try this :

document.addEventListener('DOMContentLoaded', (event) => {
  var vid = document.getElementById("wistia_simple_video_57");
  vid.ontimeupdate = function() {myFunction()};
     function myFunction() {
//   if(Math.round(vid.currentTime) > 2){
    console.log('duration',Math.round(vid.currentTime))  }
    //  }

})
  • Related