Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shorter form of writing jQuery $(document).ready function

I use a lot of jQuery, so I have to keep typing out the $(document).ready function to put the jQuery code. Is there a shorter form of the function?

like image 543
Samuel Liew Avatar asked Dec 04 '22 19:12

Samuel Liew


1 Answers

The three following syntaxes are allowed:

Syntax 1

$(document).ready(function)

Syntax 2

$().ready(function)

Syntax 3

$(function)

Update:

Additionally, from version 1.9 onwards:

$(window).on('load', null, function)
$(document).on('ready', null, function)
like image 167
Samuel Liew Avatar answered Dec 08 '22 05:12

Samuel Liew