jQuery

jQuery Document Ready with Shortcuts / Shorthand notation

Did you ever want to trigger an action automatically upon page load? You can now do it using document ready function. In this article, I will be discussing different ways of using jQuery document ready with Shortcuts / Shorthand notation.

jQuery Document Ready with Shortcuts / Shorthand notation

jQuery Document Ready Function

$(document).ready(function() {
// Your code here
alert('Page loaded');
});

jQuery Document Ready Function Shortcut

$(function() {
// Your code here
alert('Page loaded');
});

jQuery Document Ready Function – noConflict version

jQuery.noConflict();
(function($) {
$(function() {
// Your code here
alert('Page loaded');
});
})(jQuery);

The noConflict version is very useful when you are working with multiple javascript frameworks on the same page and do not want the frameworks to clash with each other.

Simple, isn’t it?

Do you know of any other ways to declare jQuery $(document).ready()? Feel free to suggest by commenting below.

Share your thoughts, comment below now!

*

*