DOM is ready
jQuery(function ($) {
// do something
});
Check if element exists
if ( $("#mydiv").length ) {
// do something here
}
Check viewport width
var vw = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0)
if (vw > 1024) {
// viewport is grater than 1024px, similar to @media(min-width:1024px){}
}
Check scroll height
$(window).scroll( function() {
var value = $(this).scrollTop()
// hide logo when scrolled below 120px
value > 120 ? $('#logo').addClass('hidden') : $('#logo').removeClass('hidden')
}