$(window).resize不工作,我遗漏了什么?
所以我有这个页面,有一个350px宽度的垂直菜单,水平居中。这些链接会打开显示不同内容的iframe。显示外部站点的iframe通过:$("#iframeweb").width($(document).width() - $('#menu').width())获得宽度,这样它就会填满屏幕,将菜单推到一边。
该部分工作,但它也需要改变宽度的大小调整窗口,但它不做任何事情…
代码:
<div id="wrapper">
<div id="outer">
<div id="inner">
<iframe name="iframeweb" id="iframeweb"></iframe>
<div id="menu">
</div>
<iframe name="iframeA4" id="iframeA4"></iframe>
</div>
</div>
</div>
<script type="text/javascript">
$(window).resize(function() {
$("#iframeweb").width($(document).width() - $('#menu').width());
};
</script>
<script type="text/javascript">
$("#linkA4").click(function(){
$("#iframeA4")
.hide('fast')
.animate({"width": "0px"}, 'fast')
.animate({"width": "210mm"}, 'fast')
.show('fast');
$("#iframeweb").hide('fast');
});
$("#linkweb").click(function(){
$("#iframeA4")
.animate({"width": "0px"}, 'fast')
.hide('fast');
$("#iframeweb")
.hide('fast')
.width($(document).width() - $('#menu').width())
.show('fast');
});
</script>发布于 2013-01-23 05:46:17
您有一个简单的语法错误,关闭括号
$(window).resize(function() {
$("#iframeweb").width($(document).width() - $('#menu').width());
}); // <--https://stackoverflow.com/questions/14468572
复制相似问题