How to resize a window using JQuery?

2020-02-12 03:45发布

问题:

JQuery has an event called resize using which you can add an event handler when the window is resized e.g.

$(window).resize(function () {
// code here
});

What I'd need is to resize the window using a JQuery command; would that be possible?

e.g. $(window).resize(-1, -1); // to decrease/increase the width and height of the window

Thanks

回答1:

Try to use this, its a pure javascript no JQuery involved.

window.resizeTo(width, height);


回答2:

sorry looks like that binds an event handler to the "resize" JavaScript event, or trigger that event on an element.

see: http://api.jquery.com/resize/