我如何在網頁中初始化 jQuery?


在網頁中初始化 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>

更新於:2020 年 2 月 14 日

2 千 + 次瀏覽

開啟你的職業生涯

完成課程獲得認證

開始
廣告
© . All rights reserved.