开发者

Entry point for jquery document

开发者 https://www.devze.com 2023-02-27 14:41 出处:网络
In every JQuery tutorial the entry point is always lik开发者_如何学Pythone this: $(document).ready(function() {

In every JQuery tutorial the entry point is always lik开发者_如何学Pythone this:

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

But in sdoc project it has different entry point as for my novice's view. Here's the code snippet and there the full file:

<script type="text/javascript" charset="utf-8">
    //<![CDATA[
    function placeholder() {
        ...
    }
    $(function() {
       placeholder();
       ...
    })
    //]]>
</script>

The question: Is $(function()..) the entry point for jquery script? And if it does why it differ from traditional approach? Thanks


It's the same. From the jQuery documentation for .ready():

All three of the following syntaxes are equivalent:

$(document).ready(handler)
$().ready(handler) (this is not recommended)
$(handler)


$(function() { ... }) is just short hand for $(document).ready(function() { ... })

0

精彩评论

暂无评论...
验证码 换一张
取 消