jquery resize() method
Translation results:
resize
UK [ˌri:ˈsaɪz] US [,ri'saɪz]
v.Resize
jquery resize() methodsyntax
Function:When the browser window is resized, the resize event occurs. The resize() method triggers the resize event, or specifies a function to run when the resize event occurs.
Trigger the resize event syntax: $(selector).resize()
Bind the function to the resize event syntax: $ (selector).resize(function)
Parameters:
Parameters | Description |
function | Optional. Specifies the function to run when the resize event occurs. |
jquery resize() methodexample
<html> <head> <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.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>
Click the "Run instance" button to view the online instance