jQuery调整iframe高度

这段代码传递给了我。 它使我的iframe设置为屏幕高度的100%:

jQuery(document).ready(function(){var height = $(window).height(); $('iframe').css('height', height) }); 

我是javascript的新手。 如何编辑此代码使其设置为90%高度而不是100%? 此外,此代码定位所有iframe,是否有任何方法可以使其定位到特定的iframe(通过其ID或NAME值)? 如果你愿意,你可以在这里摆弄这段代码: http : //jsfiddle.net/VurLy/

将它乘以90%?

 jQuery(document).ready(function() { var height = $(window).height(); $('iframe').css('height', height * 0.9 | 0); }); 

至于按ID或名称定位,只需将相应的选择器传递给$而不是'iframe'

 jQuery(document).ready(function(){ $('#YOUR_FRAME_ID_HERE').css('height', '90%') });​ 

在jquery中你可以识别出你想要的多种不同的方式,最受欢迎的是像这样的$(’#scoop’)或类,如$(’。scoop’) – 如果这个类是scoop

这就是你如何识别你想要的特定iFrame,然后像这样改变高度

  jQuery(document).ready(function() { var height = $(window).height(); $('#scoop').css('height', '90%'); });