Reputation: 2615
I'm trying to write a function that hides some text that overlays a video placed on the page through MEJS (the core wordpress integration).
I'm displaying it through the wp_video_shortcode()
function, so I'm not actually having to write any JS to get the player to display etc.
I've tried writing a bit of poor code that just checks for a click on the containing div and hides the text, then another click shows it. But I feel like I should be doing something a bit more elegant than that.
Any ideas?
Here's the code I have so far:
$('.wp-video').on('click', function() {
if( $('.video-title').is(':visible') ) {
$('.video-title').fadeOut('2000');
} else {
$('.video-title').fadeIn('2000');
}
});
Upvotes: 0
Views: 553
Reputation: 51
you can use jquery toggle function to avoid extra "if" statement
$('.wp-video').on('click', function() {
$('.video-title').toggle(2000);
});
Upvotes: 1