簡體   English   中英

如何刪除iframe主體類(jQuery / JS)

[英]How to remove iframe body class (JQuery / JS)

我有以下代碼:

<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肢體類嗎? 謝謝。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM