Back to Blog

jQuery Tips, Tricks and Resources

Jan 2, 2022 Updated: Jan 2, 2022

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')
}

Plugins

  1. Lightcase Lightbox
Contact

Got A Question For Me?

Feel free to ask anything directly on call or fill the form and I will contact back within few hours.