Florin Simion Florin Simion - 10 months ago 70
jQuery Question

Jquery constantly check if a class is added

I'm trying to display an element when a video is paused.
I'm using video.js, and currently, classes are added if the video is played, paused, finished etc.

What I can't do is to check using .hasClass() and display the element.
So far I'm using this:

if ($('.video-js').hasClass('vjs-paused')) {
else {


I guess I need to check any changes constantly but i don't really know how to do it.

I've also seen a plugin called watch but not sure how to use it.

This is a codepen:



It seems like videojs isn't really jQuery compatible as the other answer seems to suggest.

This seems to work however:

player.on('pause', function () {

player.on('play', function () {

See CodePen