How to add an if condition so that nothing breaks, or otherwise solve this problem?

In general, there is a code:

 function resizeHeight() { var height_wrap = $('#wrap_fixed').height() + 39; var result = $('.page .chord_text pre').css("min-height", height_wrap); }; resizeHeight(); $(window).resize(function() { resizeHeight(); }); 

It is necessary that it only works with a window width greater than 992px . And when the window width was changed (resize) worked again.

  • one
    Please clarify the question. It's not entirely clear what you want to do. - Aquinary
  • It is necessary that he (the code that I wrote) worked only from the width of the window above 992px. And when the window width was changed (resize) it worked again. - Victor Victor
  • Those. You can not add an if-condition with checking the width of the browser window? - Aquinary
  • If you do not know how to solve, please do not write. - Victor Victor

1 answer 1

 function resizeHeight() { var height_wrap = $('#wrap_fixed').height() + 39; var result = $('.page .chord_text pre').css("min-height", height_wrap); if ($(window).width() < 960){ result = $('.page .chord_text pre').css("min-height", "auto"); } }; resizeHeight(); $(window).resize(function() { resizeHeight(); }); 
  • I answered my question. - Victor Victor
  • Thank! Please, could you add a clarification on how exactly you decided and why you should decide this way? - Nicolas Chabanovsky
  • In fact, mene has no deep knowledge of javascript, I am just starting to study it, so I can’t say that my decision is the right one. I now have the main thing to work. - Victor Victor