0
Q:

jquery document ready shorthand

// A $( document ).ready() block.
$( document ).ready(function() {
    console.log( "ready!" );
});
1
// A jQuery( document ).ready() block.
jQuery( document ).ready(function() {
    console.log( "ready!" );
});
14
$( document ).ready(function() {
    console.log( "ready!" );
});
2
$( document ).ready(function() {
    console.log( "ready!" );
});
3
$(function(){ 
	//jQuery code here 
});
1
$(function() {
  // Handler for .ready() called.
});
3
The .ready() method is typically used with an anonymous function:
$( document ).ready(function() {
  // Handler for .ready() called.
});

Which is equivalent to the recommended way of calling:
$(function() {
  // Handler for .ready() called.
});
3
jQuery(function() {
    // Code here
});
0
// Pass jQuery to a self executing function (closure) that maps it to the dollar sign so it can't be overwritten by another library in the scope of its execution
(function( $ ){
  $.fn.myPlugin = function() {
    // Do your awesome plugin stuff here
  };
})( jQuery );
0

  
    $(document).ready(function(){
  $("button").click(function(){
    $("p").slideToggle();
  });
 });
  
 
0
$(document).ready(() => {
	console.log('ready');
});
0

New to Communities?

Join the community