Consider the following code segment :-
jQuery(document).ready(function($){
var window_width=$(window).width();
function myresize(){
window_width=$(window).width();
console.log('============window width='+window_width+' =========================');
}
$(window).resize(myresize);
if (window_width<options.hide_width){
console.log('============window width='+window_width+' =========================');
}
else
{
console.log('============window width='+window_width+' =========================');
});`
When I resize the correct value for window_width gets logged. However, the conditional code underneath still behaves as if I have not resized. If I then do a page refresh the correct condition runs, and logs the new window size.
So my question is, why is the correct conditional part not running after a resize if the value of window_width is correct?
I am still fairly new to jquery, so please forgive my ignorance if it's something daft, but I am going around in square circles here, and have been unable to google any sort of answer. The numerous similar questions about this on SO are also getting me nowhere.
Thank you.