How can I stop a video with JavaScript in Youtube?

JavascriptWeb DevelopmentFront End Technology

To stop a video you need a valid reference to the embedded player. With Firebug, inspect your page and HTML DOM element id of “playerid” should identify the player.

Here’s an example:

<embed id="player_id" width="100%" height="100%" allowfullscreen="true"
   allowscriptaccess="always" quality="high" bgcolor="#FFFFFFF" name="playerid"

To stop the video with JavaScript, you need the reference to the player (player_id) and try the following code snippet:

var player = document.getElementById('player_id');
Published on 07-Feb-2018 08:52:58