Hello I have a wordpress page that im trying to make it so that when someone hits my page with the #click_approved parameter on the url- it triggers a link with data-video attribute to open a modal. So far i drafted this JS but no luck
<script>
if(document.URL.indexOf("#click_approved") >= 0) {
document.querySelector('[data-video-id="5MS_V0SpRL8"]').click();
}
</script>
also tried this
<script>
var element = document.querySelector("a[data-video-id='5MS_V0SpRL8']");
if(document.URL.indexOf('#click_approved') >= 0) {
setTimeout(function(){element.click();}, 5000);
}
</script>
this is the page I'm trying to get the function to work on
https://www.homecarepulse.com/home-care-tv/recruitment-retention/#click_approved
any help is appreciated!
from click a element with data-video-id on page load with javascript?
No comments:
Post a Comment