jQuery 事件 - resize() 方法
2013-11-15 16:36
351 查看
1.定义
当调整浏览器窗口大小时,发生扔resize事件。
2.语法
1).$(选择器).resize();
2).$(选择器).resize(function(){});
3.例子:
1). 例子1
<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript">
x=0;
$(document).ready(function(){
$(window).resize(function() {
$("span").text(x+=1);
});
$("button").click(function(){
$(window).resize();
});
});
</script>
</head>
<body>
<p>窗口的大小被调整了 <span>0</span> 次。</p>
<p>请试着调整浏览器窗口的大小。</p>
<button>触发窗口的 resize 事件</button>
</body>
</html>
2).例子2
<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript">
x=0;
$(document).ready(function(){
$(window).resize(function() {
$("span").text(x+=1);
});
});
</script>
</head>
<body>
<p>窗口大小被调整过 <span>0</span> 次。</p>
<p>请试着重新调整浏览器窗口的大小。</p>
</body>
</html>
当调整浏览器窗口大小时,发生扔resize事件。
2.语法
1).$(选择器).resize();
2).$(选择器).resize(function(){});
3.例子:
1). 例子1
<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript">
x=0;
$(document).ready(function(){
$(window).resize(function() {
$("span").text(x+=1);
});
$("button").click(function(){
$(window).resize();
});
});
</script>
</head>
<body>
<p>窗口的大小被调整了 <span>0</span> 次。</p>
<p>请试着调整浏览器窗口的大小。</p>
<button>触发窗口的 resize 事件</button>
</body>
</html>
2).例子2
<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript">
x=0;
$(document).ready(function(){
$(window).resize(function() {
$("span").text(x+=1);
});
});
</script>
</head>
<body>
<p>窗口大小被调整过 <span>0</span> 次。</p>
<p>请试着重新调整浏览器窗口的大小。</p>
</body>
</html>
相关文章推荐
- jquery.form.js 提交教会你怎样用ajaxForm
- jQuery .tmpl(), .template()学习资料小结
- jquery获取元素值
- 简单的Jquery遮罩层代码实例
- jquery+json实现数据列表分页
- jquery.autocomplete自动提示
- Jquery实现页面上所有的checkbox只能选中一个
- jQuery Mobile里xxx怎么用呀? (事件篇)
- Jquery+CSS实现缩略图幻灯片
- jquery.validate格式验证
- Jquery操作radio,checkbox,select表单操作实现代码
- jquery.cookie.js用法详解
- jquery取值
- Jquery用法
- IE 10, HTML5 and jQuery 2.x - JavaScript runtime error: 'JSON' is undefined
- 50个必备的实用jQuery代码段
- jQuery 实现拖动浮动层
- jQuery事件之鼠标事件
- JQuery Highcharts 动态图表生成方法
- jquery获取url参数值