0

I am trying to change the width of windows on dropdown change event. But I am stuck on it. The window is not resizing. here is my code:

 $(".optionextended-narrow-swap-select select").change(function() {
    $(window).resize(function(){
    // here comes the code for resize. 

     alert (""); // for now it is not event alerting

    });

});

Please help me to resize window. I just want to reduce it by 1 px just to trigger some event.

Faran Khan
  • 1,495
  • 4
  • 14
  • 26

3 Answers3

1

You can simply use:

window.resizeTo(window.innerWidth-1, window.innerHeight);

resizeTo(): The resizeTo() method resizes a window to the specified width and height.

For reducing width by 1 px: Get current width usingwindow.innerWidth and subtract 1 from it.

Milind Anantwar
  • 81,290
  • 25
  • 94
  • 125
0

you need to trigger the window resize event.

Check the below article.

How to trigger the window resize event in JavaScript?

Community
  • 1
  • 1
Nadeem
  • 1
0

Try like

$(".optionextended-narrow-swap-select select").change(function() {
$(window).trigger( "resize" );
});

This was demo How it works

fiddle

Arunkumar
  • 5,150
  • 4
  • 28
  • 40