jQuery调整iframe高度 [英] jQuery adjusting iframe height
本文介绍了jQuery调整iframe高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
此代码已传递给我。它使我的iframe设置为屏幕高度的100%:
This code was passed to me. It makes my iframe set to 100% height of the screen:
jQuery(document).ready(function(){var height = $(window).height();
$('iframe').css('height', height)
});
我是javascript的新手。如何编辑此代码使其设置为90%高度而不是100%?此外,此代码定位所有iframe,是否有任何方法可以使其定位到特定的iframe(通过其ID或NAME值)?如果您愿意,可以在此处摆弄此代码: http://jsfiddle.net/VurLy/
I am new to javascript. How can I edit this code to make it set to 90% height rather than 100%? Also, this code targets all iframes, is there any way to make it target a specific iframe (by its ID or NAME value)? You can fiddle with this code here if you wish: http://jsfiddle.net/VurLy/
推荐答案
将其乘以90%?
jQuery(document).ready(function() {
var height = $(window).height();
$('iframe').css('height', height * 0.9 | 0);
});
至于按ID或名称定位,只需将适当的选择器传递给 $
而不是'iframe'
。
As for targeting by ID or name, just pass the appropriate selector to $
instead of 'iframe'
.
这篇关于jQuery调整iframe高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文