Here is the JSFiddle http://jsfiddle.net/thornwalker/3LQjS/
I'm trying to get it to run on my wordpress blog and having no luck. My skill is novice at best, but up until now I've been able to muddle through.
This is the code I have in my functions.php (in my main theme, if I copy the functions.php to my child theme it won't run.)
function videoswitch() {
wp_enqueue_script('videoswitch', get_template_directory_uri() . '/js/videoswitch.js',
array('jquery')
);
}
add_action('wp_enqueue_scripts', 'videoswitch');
Finally, here's the videoswitch.js
jQuery(document).ready(function($){
var directionsVar = '<video autoplay="" loop=""><source src="directionsVid.mp4" type="video/mp4"></video>';
var storyVar = '<video autoplay="" loop=""><source src="storyVid.mp4" type="video/mp4"></video>';
$("#directions").hover(function () {
$("#video-container").empty();
$("#video-container").append(directionsVar);
});
$("#story").click(function () {
$("#video-container").empty();
$("#video-container").append(storyVar);
});
});
Any help would be greatly appreciated.
get_template_directory_uri()always refers to the parent theme. Is this what you want?get_stylesheet_directory_uri().