0

I have a project in development and I want to use this technique to load a background video element.

This should load into the large white box below the purple nav bar. So far I have added the script to my enqueue-scripts.php file:

wp_enqueue_script( 'video', get_template_directory_uri() . '/assets/js/site/video.js', 
    array(), '', true );

It seems to be working correctly, as I can see the script video.js is listed in the footer.

The problem is when the script runs, the video element doesn't receive the video source attribute correctly and remains 'undefined'.

Any suggestions?

1 Answer 1

2

Hard to tell exactly what's happening without checking your code, but if you inspect your home page, you'll see that the video element is being added outside the BODY tag (check attachment below). That might be the reason your script can't find the video source.

Chrome Dev Tools Screenshot

1
  • Thanks for the help DM78. That had been confusing me - and further investigation has put me on the right path and I've now fixed my issue. The problem was conflicting class names. the opening html tag had a 'video' class hence the video element being added at the top and it not running properly. I've changed the class name on the video Bg containers and script and it's now all good (on my local version) - Cheers
    – easYnow
    Oct 7, 2015 at 8:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.