方法一:

$(function(){// Bind the resize event. When any test element's size changes, update its// corresponding info div.$('.test').resize(function(){var elem = $(this);// Update the info div width and height - replace this with your own code// to do something useful!elem.closest('.container').find('.info').text( this.tagName + ' width: ' + elem.width() + ', height: ' + elem.height() );});// Update all info divs immediately.$('.test').resize();// Add text after inline "add text" links.$('.add_text').click(function(e){e.preventDefault();$(this).parent().append( ' Adding some more text, to grow the parent container!' );});// Resize manually when the link is clicked, but only for the first paragraph.$('.add_text:first').click(function(){$(this).parent().resize();});
});
$(function(){// Bind the resize event. When the window size changes, update its corresponding// info div.$(window).resize(function(){var elem = $(this);// Update the info div width and height - replace this with your own code// to do something useful!$('#window-info').text( 'window width: ' + elem.width() + ', height: ' + elem.height() );});// Updates the info div immediately.$(window).resize();
});

原文:http://benalman.com/code/projects/jquery-resize/examples/resize/

方法二:插件 jQuery resizeend

jQuery resizeend

A jQuery plugin that allows for window resize-end event handling.

Demo

See the demo here.

Usage

Include both the jQuery library and the resizeend plugin in your project:

<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="js/jquery.resizeend.js"></script>

Execute the resizeend method to an element, instatiate options (if so desired), and run a callback functions:

$(window).resizeend({delay : 250
}, function() {// ...
});

Or bind an element to the event, passing in options and event handler:

$(window).on('resizeend', 250, function() {// ...
});

If you want to use the default delay setting of 250ms, simply don't include the options object:

$(window).resizeend(function() {// ...
});

Options

The only option available is the delay time (in milliseconds) to execute the callback after the browser has stopped being resized. The default value is 250ms. This can be passed as either a number or object:

// As a number
$(window).on('resizeend', 250, function() {// ...
});// As an object
$(window).on('resizeend', { delay : 250 }, function() {// ...
});

License

This plugin is licensed under the MIT license. A copy of the license is included in this package.

项目地址:https://github.com/nielse63/jquery.resizeend

主页:http://nielse63.github.io/jquery.resizeend/

下载:jquery.resizeend-master

转自:jquery监听窗口大小改变事件jquery.resizeend

jquery监听窗口大小改变事件jquery.resizeend相关推荐

  1. html屏幕滚动事件监听,JQuery监听页面滚动事件

    1.当前滚动的地方的窗口顶端到整个页面顶端的距离: var scrollTop = $(window).scrollTop(); 2.获取指定元素的页面位置: $(obj).offset().top; ...

  2. 综合设计一个OPPE主页--页面的插件引用(animate.css)--d动画的使用--滚轮或鼠标到该位置时,才有动画的切换---所以我们需要用jquery监听鼠标滚轮的滚动事件

    Animate.css | A cross-browser library of CSS animations. 里面有许多css的效果 首先使用 animate.css文件 link rel=&qu ...

  3. jQuery 监听修改文本框事件

    在开发中,有时我们需要对 input 的 value 值变化作实时响应.比如文本输入框的实时字数统计功能,要求文本框内容改变时就要触发相关的统计行为.不管这个内容是键盘输入的,还是鼠标粘贴进来的.1, ...

  4. Jquery监听onChange事件

    Jquery监听onChange事件 $(document).ready(function () {$("#控件ID").change(function () {var organ ...

  5. jquery 监听td点击事件_React 事件 | 1. React 中的事件委托

    说到 React 的事件,也算是 React 的一个非常有亮点的优化,它在原生事件体系的基础上,单独实现了一套事件机制.想要了解这个机制,首先的了解下什么是事件委托以及事件委托的好处. 事件委托 假设 ...

  6. html监听页面滚动高度,jquery如何监听滚动条事件?

    jquery如何监听滚动条事件?下面本篇文章给大家介绍一下.有一定的参考价值,有需要的朋友可以参考一下,希望对大家有所帮助. 问题: 在浏览很多网页中都会发现,当滚动条滚动到一定的位置的时候就出显示一 ...

  7. jquery 监听td点击事件_安卓开发监听点击事件的一种方法

    本人是菜鸟一只,学习安卓纯属兴趣.没有真正上过编程课程,所有知识都是在网上获取的.今天分享的是监听点击事件的一个方法,这个方法的好处是代码较简洁. 如图,点击保存时,把上面的数据入库. 实现如下: 在 ...

  8. php 监听条码枪输入,使用jQuery监听扫码枪输入并禁止手动输入的实现方法

    @(知识点总结)[jquery|扫码抢] 基于jQuery的扫码枪监听.如果只是想实现监听获取条码扫码信息,可以直接拿来使用,如果有更多的条码判断处理逻辑需要自己扩展. 一.功能需求 使用扫码枪扫描条 ...

  9. php 监听条码枪输入,使用jQuery监听扫码枪输入并禁止手动输入的实现方法(推荐)...

    基于jQuery的扫码枪监听.如果只是想实现监听获取条码扫码信息,可以直接拿来使用,如果有更多的条码判断处理逻辑需要自己扩展. 一.功能需求 使用扫码枪扫描条码,在一个web页面监听获取扫码枪的数据, ...

最新文章

  1. Oracle中merge into的使用
  2. d3设置line长度_使用d3画一些基本的图形
  3. SAP中执行没有权限的事务
  4. Java实现的简单的WebService服务发布和Client调用例子
  5. 台式无线网卡管理服务器,台式电脑设置wifi上网
  6. 一款非常好看的雷姆背景的时间单页(附雷姆图片)
  7. Android应用开发实例篇(1)-----简易涂鸦板
  8. datastage java_使用 DataStage Java Integration Stage 和 Java Pack 从 Excel 源文件中
  9. 二叉树最简单的遍历方式——二叉树的层序遍历
  10. Git工作流中常见的三种分支策略:GitFlow、GitHubFlow和GitLabFlow
  11. 用python绘制叠加等边三角形_python 叠加等边三角形的绘制的实现
  12. Vue+Vue Router+Vuex页面演示
  13. java 合并两个列表_如何在Java中合并两个列表?
  14. 【以太坊开发】发币指南--进阶篇
  15. IBM宣布:成功研制出了量子计算机原型机,量子计算机商业化正在加速!
  16. Linux 端口转发 端口映射
  17. 熵权法计算权重(java版)
  18. 全电子计算机联锁厂家,传统计算机联锁与全电子计算机联锁对比分析
  19. 密码(N Or M?)
  20. [4G5G专题-131]:流程 - LTE的功率控制

热门文章

  1. 数组逆序重存放(信息学奥赛一本通-T1105)
  2. 字符菱形(信息学奥赛一本通-T1028)
  3. vue 取数组第一个值_Vue如何循环提取对象数组中的值
  4. java 两层while_java – while while循环满足2个条件之一
  5. OpenCV辅助对象(help objects)(1)_TermCriteria
  6. 删除python类中所有未使用的方法?
  7. MVVM和MVC有什么区别
  8. [SAP2000] 简单桁架受力求解过程
  9. 短网址PHP源码Shortny
  10. java for update 无效_java.sql.BatchUpdateException:调用中的无效参数