jquery - 如何检查变量是否是视频标签?

标签 jquery html css

我正在尝试检查所选元素是否为视频。

我的 html

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

我的 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')
   }
})

如何检测 newElement 是否为 video 标签?非常感谢!

最佳答案

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

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

关于jquery - 如何检查变量是否是视频标签?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21590525/

相关文章:

javascript - 使用 jquery 从数组中获取唯一数据

html - 带有剪辑路径的模糊图像边框效果

css - 如何将音频文件分配给静音/取消静音切换按钮?

jquery - 图像上的 div float 位置

html - 使用 Bootstrap 使用单选按钮进行选项卡控制

html - 如何在菜单的列中显示几个选项

jquery - jQuery css() 方法上的渐变过滤器

jquery - 如何在 Rails select_tag 上显示 Font Awesome 图标

javascript - Meteor:循环模板的模板级别订阅或所有订阅完成时

javascript - 将字母分配给特定范围内的数字值