• Resolved tvalades

    (@tvalades)


    Good morning how are you?
    A few weeks ago I made a design for the home page of the page that I add in which the sections contain a background video that does not play until you hover and stops playing when you leave the section.
    I left it working perfectly until yesterday when I found that the effect was not working.

    I use Elementor to layout the web so I add the row to which I put the background video and add the class ‘video’.

    I create a video.js file in the assets / js folder of my theme with the following code:

    jQuery(document).ready(function() {
    
    $("video").removeAttr("autoplay");
    var figure = $(".video").hover( hoverVideo, hideVideo );
    
    function hoverVideo(e) {  
        $('video', this).get(0).play(); 
    }
    
    function hideVideo(e) {
        $('video', this).get(0).pause(); 
    }
    });

    and in the functions.php of my theme I add:

    add_action('wp_enqueue_scripts', 'video_js');
    function video_js() {
        wp_enqueue_script( 'video', get_template_directory_uri() . '/assets/js/video.js', array(), '1.0.0', true );
    }

    I don’t know why it stopped working. It is a test environment where no updates or changes have been made since that design was made.

    Thanks for the help

    The page I need help with: [log in to see the link]

  • The topic ‘Hover video stopped working’ is closed to new replies.