我得到以下 HTML:
<video width="552" height="572" id="video" autoplay preload="none" poster="image.png">
我将如何从元素autoplay中完全删除?<video>
我尝试过类似以下的方法:
//Attempt
jQuery('video').remove('autoplay');
//Attempt
jQuery( 'video' ).removeClass( 'autoplay' );
我得到以下 HTML:
<video width="552" height="572" id="video" autoplay preload="none" poster="image.png">
我将如何从元素autoplay中完全删除?<video>
我尝试过类似以下的方法:
//Attempt
jQuery('video').remove('autoplay');
//Attempt
jQuery( 'video' ).removeClass( 'autoplay' );
去除:
纯javascript:
document.getElementsByTagName('video')[0].removeAttribute('autoplay');
或者
document.getElementById('VIDEO_ID').removeAttribute('autoplay');
使用 jQuery:
$('video').removeAttr("autoplay");
加上:
纯javascript:
document.getElementsByTagName('video')[0].setAttribute('autoplay','');
或者
document.getElementById('VIDEO_ID').setAttribute('autoplay','');
使用 jQuery:
$('video').attr("autoplay","");
autoplay是一个属性,因此使用该removeAttr属性。
http://api.jquery.com/removeAttr/
$(selector).removeAttr('autoplay');
您可以使用以下.removeAttr()方法执行此操作:
jQuery( 'video' ).removeAttr( 'autoplay' );
这将从每个元素中删除autoplay属性。video
jQuery( '#video' ).removeAttr( 'autoplay' );
这将从IDautoplay的元素中删除该属性。 video
您可以使用该.removeAttr()功能。
jQuery('video').removeAttr('autoplay');
没有测试,但应该可以
尝试:
jquery('video').removeAttr('autoplay');