如何移除iframe主体类(JQuery / JS)

How to remove iframe body class (JQuery / JS)

本文关键字:JQuery JS 何移 iframe 主体      更新时间:2023-09-26

我有这样的代码:

<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);

http://youmightnotneedjquery.com/

所以如果你想通过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','');