我有这样的代码:
<ul class="heroBx">
<li>
<iframe width="980" height="370" src="heroBanner/heroElantra/index.html" frameborder="0" scrolling="no"></iframe>
</li>
<li>
<iframe width="980" height="370" src="heroBanner/heroH1/index.html" frameborder="0" scrolling="no"></iframe>
</li>
<li>
<iframe width="980" height="370" src="heroBanner/heroStarex/index.html" frameborder="0" scrolling="no"></iframe>
</li>
<li>
<iframe width="980" height="370" src="heroBanner/heroTucson/index.html" frameborder="0" scrolling="no"></iframe>
</li>
<li>
<iframe width="980" height="370" src="heroBanner/heroVeloster/index.html" frameborder="0" scrolling="no"></iframe>
</li>
</ul>
我可以移除iframe body类吗?谢谢你。
document.querySelectorAll('.my #awesome selector');
和
el.classList.remove(className);
所以如果你想通过JavaScript从DOM中的所有ul
元素中删除heroBx
类:
var uls = document.querySelectorAll('ul');
for(var i = 0; i < uls.length; i++) {
uls[i].classList.remove('heroBx');
}
如果只有一个ul
作为目标,您可以简单地:
var ul = document.querySelector('ul');
ul.classList.remove('heroBx');
试试这个:
$('#iframe').contents().find('body').attr('class','');