js&jquery操作页面中iframe内的dom元素

$("#iframe1").contents().find("#news_text").html("");

iframe1:页面中的iframe的ID;

news_text:iframe内需要被操作的元素的ID;

JS代码如下:

document.getElementById('iframe1').contentWindow.document.getElementById('news_text').style.color='red' 

    未经允许不得转载:任鹏个人博客 » js&jquery操作页面中iframe内的dom元素

    赞 (4) 打赏

    评论 0

    取消
    • 昵称 (必填)
    • 邮箱 (必填)
    • 网址

    觉得文章有用就打赏一下文章作者

    支付宝扫一扫打赏

    微信扫一扫打赏