1. 默认情况下jquery的resize
$(window).resize(function () { console.log(111); });//只会响应浏览器的窗口大小变化
如果要resize想用dom元素的宽高变化,则需要引入jquery的另外一个插件
(下载地址:https://cdn.bootcss.com/jquery-resize/1.1/jquery.ba-resize.min.js),内容如下:
/* * jQuery resize event - v1.1 - 3/14/2010 * http://benalman.com/projects/jquery-resize-plugin/ * * Copyright (c) 2010 "Cowboy" Ben Alman * Dual licensed under the MIT and GPL licenses. * http://benalman.com/about/license/ */ (function($,h,c){var a=$([]),e=$.resize=$.extend($.resize,{}),i,k="setTimeout",j="resize",d=j+"-special-event",b="delay",f="throttleWindow";e[b]=250;e[f]=true;$.event.special[j]={setup:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.add(l);$.data(this,d