Close Bootstrap modal with jQuery or Javascript on windows resize -


how can close bootstrap modal if browser windows width less 700px? have tried jquery this:

$(window).resize(function() {   if ($(window).width() < 700) {      $("#modal").hide( 0, function() {});     $("body").removeclass("modal-open");     $(".modal-backdrop").hide( 0, function() {});  } }); 

i have content of modal in 50% of page , when window less 700px content moves modal. working great if resize windows method above have problems , have press button open modal twice. if dont resize windows , close modal x works great have find way close modal when windows resized.

i believe should try

$('#modal').modal('hide'); 

instead of

$('#modal').hide(); 

Comments

Popular posts from this blog

javascript - How to diff two immutable objects -

javascript - React.js: onClick function from child to parent -

c# - How can I have the VS Debugger break in the correct location for exceptions thrown in Async methods in a Console App? -