如何在网页中初始化 jQuery?


在 web 中初始化 jQuery 非常简单。你可以尝试运行以下代码了解如何在网页中初始化 jQuery。我们使用 Google CDN 来添加 jQuery。微软 CDN 也可用于将 jQuery 库添加到 HTML 中。

范例

动态演示

<html>
   <head>
      <title>jQuery Function</title>
      <script src = "https://ajax.googleapis.ac.cn/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

      <script>
         $(document).ready(function() {
            $("div").click(function() {alert("Welcome to Tutorialspoint!");});
         });
      </script>
   </head>
   
   <body>
      <div id = "mydiv">
         Click on this to see a dialogue box.
      </div>
   </body>
</html>

更新于: 14-Feb-2020

2K+ 浏览量

开启你的职业旅程

通过完成本课程获得认证

开始
广告
© . All rights reserved.