FlyingCat
FlyingCat

Reputation: 14250

How to check if a variable is an video tag?

I am trying to check if the selected element is an video.

MY html

<div class='component'>
    <video><source.../></video>
</div>

My js

$('.component').on('click', function(){
  var newElement = $(this).children().first();  //I need to keep the children().first() for  
                                                other purpose

  if(newElement.find('video').length){   //this will never be true..
        alert('is video')
   }
})

How do I detect if the newElement is an video tag? Thanks a lot!

Upvotes: 0

Views: 46

Answers (1)

Blazemonger
Blazemonger

Reputation: 92893

if (newElement.is('video')) {

http://api.jquery.com/is/

Upvotes: 2

Related Questions