【问题标题】:Change height of an iframe on hover?悬停时更改 iframe 的高度?
【发布时间】:2010-03-10 21:28:54
【问题描述】:

如何使用 jQuery 在悬停时更改 iFrame 的高度?

我试过这个:

<script type="text/javascript"> 
  $(document).ready(function(){
    $(".googlemaps").hover( function(){
      $('#googlemaps').height(300);
    });
  });
</script>

我的 iframe 是:

<div class="googlemaps">
 <xsl:variable name="location"><xsl:value-of select="DocumentEdition/Fields/Field[@Name = 'Location']" /></xsl:variable>
 <iframe id="googlemaps" width="489" height="215" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.dk/maps?f=q&amp;source=s_q&amp;hl=da&amp;geocode=&amp;q={$location}&amp;output=embed">&#160;</iframe><br /><small><a href="http://maps.google.dk/maps?f=q&amp;source=embed&amp;hl=da&amp;geocode=&amp;q=skive&amp;sll=55.869147,11.228027&amp;sspn=7.860459,28.54248&amp;ie=UTF8&amp;hq=&amp;hnear=Skive&amp;z=13&amp;ll=56.565498,9.021939" style="color:#0000FF;text-align:left">Vis stort kort</a></small>
</div>

【问题讨论】:

    标签: jquery height


    【解决方案1】:

    您的代码似乎没问题,但也试试这个:

    $('#googlemaps').attr('height', 300 + 'px');
    

    【讨论】:

      【解决方案2】:

      您的代码很好。谷歌似乎正在将 iframe 调整回原来的大小。删除 URL,您会看到。

      【讨论】:

        猜你喜欢
        • 2020-12-11
        • 2014-02-20
        • 2022-08-20
        • 1970-01-01
        • 2015-04-23
        • 2014-07-01
        • 2013-09-11
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多