Where to place JAvascript code for hover over Video Effect

does anyone know were i would put this code? in wordpress.. ive put it in funtions.php as well as the footer and header and all i get is a string error or written code

var vid = document.getElementsByTagName("video");
[].forEach.call(vid, function (item) {
    item.addEventListener('mouseover', hoverVideo, false);
    item.addEventListener('mouseout', hideVideo, false);
});

function hoverVideo(e)
{   
    this.play();
}
function hideVideo(e)
{
    this.pause();
}

its a javascript

Read More

As far as the HTML code i put that in the post or page text editor

Here is the effect im trying to acchieve-> http://jsfiddle.net/ymV8J/10/

Related posts

Leave a Reply

1 comment

  1. I usually put javascript code in footer just before closing </body> tag.

    Make sure that the javascript code is inside script tag like this:

    <script type="text/javascript"> 
    //Your javascript code
    </script>
    

    I just tried the code from jsFiddle on my development WordPress site and it works fine.

    Also for the HTML part in jsFiddle, you only need to copy code that is inside <body> tag.