resize()方法是jQuery中的一个内置方法,在浏览器窗口更改大小时使用。
null
语法:
$(selector).resize(function)
参数: 此方法接受单个参数 作用 这是可选的。它用于指定调用resize事件时要运行的函数。
返回值: 此方法返回所选元素,并增加其大小。
下面的示例演示了jQuery中的resize()方法:
例子:
<!DOCTYPE html> < html > < head > < title >The resize method</ title > < script src = </ script > <!-- jQuery code to show the working of this method --> < script > x = 0; $(document).ready(function() { $(window).resize(function() { $("p").text(x += 1); }); }); </ script > < style > div { width: 150px; height: 100px; padding: 20px; border: 2px solid green; font-size: 20px; } </ style > </ head > < body > < div > <!-- press "ctrl" and "+" key together and see the effect --> Welcome to GfG! < br > < p >0</ p > times. </ div > </ body > </ html > |
输出: 在点击任何东西之前。 在键盘上同时点击两次“ctrl”和“+”键。
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END