在页面上提供以下内容:
<iframe frameborder="0" allowtransparency="true" tabindex="0" src="" title="Rich text editor" style="width: 100%; height: 100%;" id="hi-world">
<p><span class="tipoff" title="System tooltip for search engines">Download now</span></p><p>adasdads</p><p>a</p><p><span class="tipoff" title="System tooltip for search engines">Download n1111ow</span></p>
</iframe>
以下作品:
$('#hi-world').css("width","10px");
但我想要做的是更改iFrame中的段落,这不起作用:
$('#hi-world').find('p').css("background","red");
答案 0 :(得分:4)
好吧只是想通了:
$('#hi-world').contents().find('p').css("background","red");
答案 1 :(得分:1)
第一个是更改iframe元素的css。要做到第二步,您必须访问contentDocument。如上所述,在jQuery中,您可以使用contents。