Given a video on the website and the task is to play it while hovering the cursor on the video and stop the video play on removing the cursor from the video div using jQuery events.
Example: Suppose you are in a hurry and you don’t have time to view the whole video of the article, then you can just hover over the video to see its content without opening the whole video. This method is very efficient and can be used to save data and time of the user. This approach is most commonly used on YouTube and other popular video streaming websites that allows the video to play on hover of the cursor.
Approach: One can play the video on hover using the jQuery. For this, they need to have mouseenter function that will allow the video to play on hovering the mouse cursor over the video. Similarly, one can pause the video by playing the mouseleave function of the jQuery.
Using jQuery mouseenter() Method: The mouseenter() method is an inbuilt method in jQuery which works when mouse pointer moves over the selected element.
Using jQuery mouseleave() Method: The mouseleave() method is an inbuilt method in jQuery which works when the mouse pointer leaves the selected element.