如何使用jquery更改iframe中的html

时间:2013-03-12 10:13:09

标签: jquery iframe

我在html下方动态生成了我的Iframe ID,现在我想更改我的跨度的html。

<a title="Visit Us on Google+" id="gPlus" class="addthis_button_google_plusone at300b" g:plusone:count="false">
  <div id="___plusone_0">
    <iframe width="100%" scrolling="no" frameborder="0" hspace="0" marginheight="0" marginwidth="0"
    style="position: static; top: 0px; width: 24px; margin: 0px; border-style: none; left: 0px; visibility: visible; height: 15px;"
    tabindex="0" vspace="0" id="I0_1363080003291" name="I0_1363080003291"
    src="https://plusone.google.com"
    allowtransparency="true" data-gapiattached="true" title="+1">
        <html lang="en" dir="ltr">
            <head>
            </head>
            <body class="g-rba-Dh-kQa ">
                <div class="Bg" dir="ltr" id="plusone">
                <span id="widget_bounds"><table cellspacing="0" cellpadding="0"><tbody><tr><td>
                <div class="ZRa">
                <span tabindex="0" role="button" title="" class="hAa Ro Bg" id="button" aria-label="Click here to publicly +1 this." aria-pressed="false"><div class="YIa"></div></span></div></td></tr></tbody></table></span></div>
            </body>
        </html>
    </iframe>
  </div>
</a>

现在我想使用jquery

在“title”标签中添加一些值
<div class="ZRa">
<span tabindex="0" role="button" title="" class="hAa Ro Bg" id="button" aria-label="Click here to publicly +1 this." aria-pressed="false"><div class="YIa"></div></span>
</div>

请建议!!

2 个答案:

答案 0 :(得分:0)

尝试一次,

$(document).ready(function () {
$("#___plusone_0")
    .find("iframe")
    .contents()
    .find(".hAa ")
    .attr('title', 'whatever u want');
 });

答案 1 :(得分:0)

试试这个

$('#___plusone_0').find('span#button').attr('title','yourTitle');