我有一个相当愚蠢的插件,如果源文件名以错误的文件扩展名结尾,它还不知道如何完全删除视频标签。
伪代码的工作方式如下:
Div populates with a Video element
If Video element SRC isn't a .M4V file name extension, remove the parent div including the Video element
If Video element SRC is a .M4V file extension, behaves as normal.
我现在拥有的代码不起作用,但我不确定在哪里寻找一个好的解决方案。这只是我的语法吗?
$('.aboveTheFold video').(function(){
if( $('video #postvideo').attr('src').match(/\.(m4v)/) ) {
$("#postvideo").detach().appendTo("#fold-above");
} else if {
$('#postvideo').attr('src').match(/\.(jpg)/) )
{
$('.aboveTheFold video').remove();
};
}
});
一种简化的方法是:
$("#postvideo").attr('src').match(/\.(jpg)/) ).remove();
但是控制台现在告诉我 jquery.min 中缺少一个括号,我敢肯定不是这种情况......