Jquery $(function(){}), what does it mean? [duplic

2019-08-13 02:45发布

This question already has an answer here:

In Jquery, I understand that

$() 

is there to select an element and when you do something like

$(".foo").click(function(){})

will execute function when foo class is clicked..

but when you do,

$(function(){})

does this mean you are selecting a function? it doesn't seem right to me..

2条回答
干净又极端
2楼-- · 2019-08-13 03:14

it's just a shortcut for

$(document).ready(function() {});

which will be called when the DOM ready event fires

See the documentation for .ready

查看更多
何必那么认真
3楼-- · 2019-08-13 03:29
$(function(){})

This will be your function that need to be called.

查看更多
登录 后发表回答