My jQuery script collapses content, makes title elements clickable, and shows content. I want to constrain the script to viewports smaller than 700 px.
Here is a codepen with the jQuery:
My jQuery script collapses content, makes title elements clickable, and shows content. I want to constrain the script to viewports smaller than 700 px.
Here is a codepen with the jQuery:
You can use $( window ).width();
to find the width of the window and then only execute when the width is less than 700px.
Demo - http://codepen.io/guyfedwards/pen/aBChg
If you want it to update as the window is resized you could use .resize(). e.g:
$(window).resize(function(){
if ($(window).width() <= 700){
// do something
}
});