Skip to content

ifbreakpoint.js : if Bootstrap 4 breakpoint (media query) is X do something

License

Notifications You must be signed in to change notification settings

JacobLett/IfBreakpoint

Repository files navigation

If Bootstrap 4 Breakpoint do something

Detect Bootstrap 4 breakpoints to run conditional scripts and functions

Bootstrap 4 <script src='https://cdn.rawgit.com/JacobLett/IfBreakpoint/e9fcd4fd/if-b4-breakpoint.min.js'></script>

Bootstrap 3 <script src='https://cdn.rawgit.com/JacobLett/IfBreakpoint/e9fcd4fd/if-b3-breakpoint.min.js'></script>

Are you extra-small?

// update onload
$(document).ready(function(){
  // update onload
  $("h2").text( breakpoint ); 
  
  if ( xs == true ) { 
    alert("mobile first");
  }

  // Update on window resize
  $( window ).resize( function(){
    $("h2").text( breakpoint ); 
  }); 

});