下载jQuery库后,jQuery仍然不能离线工作

jQuery not working offline still after downloading the jQuery library

本文关键字:jQuery 不能 离线 工作 库后 下载      更新时间:2023-09-26

我已经下载了jquery库,我把我所有的html,css和javascript文件在同一个文件夹。但它仍然不起作用。下面是代码

$(document).ready(function() {
  $('button').click(function() {
    $('div').fadeOut('slow');
  });
});
div {
  height: 100px;
  width: 100px;
  display: inline-block;
  background-color: green;
  border-radius: 5px;
}
<html>
<head>
  <link rel="stylesheet" type="text/css" href="x.css" />
  <script type="text/javascript" src="jquery-1.11.3.min.js"></script>
  <body>
    <div>
      <button>good</button>
    </div>
  </body>
</html>

你需要添加你自己的js文件:

<html>
<head>
 <link rel="stylesheet" type="text/css" href="x.css"/>
 <script type="text/javascript" src="jquery-1.11.3.min.js"></script>
 <script type="text/javascript" src="your-js-file.js"></script>
</head>
 <body>
  <div>
   <button>good</button>
  </div>
 </body>
</html>

你需要关闭你的head标签:

<html>
    <head>
        <link rel="stylesheet" type="text/css" href="x.css"/>
        <script type="text/javascript" src="jquery-1.11.3.min.js"></script>
    </head>
    <body>
        <div>
            <button>good</button>
        </div>
    </body>
</html>