if media query jquery

JavaScript
$(window).resize(function() {
  if ($(this).width() < 1024) {
	// your code
  } else {
    // your code
  }
});
Source

Also in JavaScript: