我将 SharePoint Server 2007 Enterprise 与 Windows Server 2008 Enterprise 一起使用。我正在使用 VSTS 2008 + C# + .Net 3.5 + ASP.Net 进行开发。我正在学习以下处理 javascript 的代码,我的困惑在于代码的 $(function(){...} 部分,何时调用它以及它的功能是什么?我没有看到任何代码调用这个函数。

<!doctype html>
<html lang="en">
<head>
    <title>Test</title>
    <link type="text/css" href="tabcontrol/themes/base/ui.all.css" rel="stylesheet" />
    <script type="text/javascript" src="tabcontrol/jquery-1.3.2.js"></script>
    <script type="text/javascript">
        $(function() {
            $("#tabs").tabs();
        });
    </script>
</head>
<body>

<div class="demo">

<div id="tabs">
    <ul>
        <li><a href="#tabs-1">tab1</a></li>
        <li><a href="#tabs-2">tab2</a></li>
    </ul>
    <div id="tabs-1">
        <p>tab1 info</p>
    </div>
    <div id="tabs-2">
        <p>tab2 info</p>
    </div>
</div>

</div>

</body>
</html>

提前致谢,
乔治

最佳答案

它来自您包含的 jQuery 库:

<script type="text/javascript" src="tabcontrol/jquery-1.3.2.js"></script>
$jQuery 函数的别名。
jQuery(callback) reference documentation :

有关更多信息,请查看 Tutorials:Introducing $(document).ready()

关于javascript - 什么是 $(function() { ... }) 函数,在以下示例中何时调用?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2081032/

10-09 15:23
查看更多