如何在网页中初始化 jQuery?

jqueryweb developmentfront end technology

在网页中初始化 jQuery 非常简单。您可以尝试运行以下代码来学习如何在网页中初始化 jQuery。我们使用 Google CDN 添加 jQuery。Microsoft CDN 也可用于将 jQuery 库添加到 HTML 中。

示例

<html>
   <head>
      <title>jQuery Function</title>
      <script src = "https://ajax.googleapis.com/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>

相关文章