Change height of an iframe on hover?

末鹿安然 提交于 2019-12-11 07:04:50

问题


How do i change the height of an iFrame, on hover, using jQuery?

I've tried this:

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

My iframe is:

<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>

回答1:


Your code seems to be fine but try this too:

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



回答2:


Your code is fine. It seems that Google is resizing the iframe back to its original size. Remove the URLs and you'll see.



来源:https://stackoverflow.com/questions/2416696/change-height-of-an-iframe-on-hover

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!