Tho*_*sCS 1 html javascript jquery
$(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>
Run Code Online (Sandbox Code Playgroud)
您有一个简单的语法错误,关闭括号
$(window).resize(function() {
$("#iframeweb").width($(document).width() - $('#menu').width());
}); // <--
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2024 次 |
| 最近记录: |