第一步:先创建一个html网页,以下:html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<div>
<div>
<input class="btnhy1" type="button" value="一楼" style="width: 80px;height: 30px; border: 2px; background: #2290E0;"/>
<input class="btnhy2" type="button" value="二楼" style="width: 80px;height: 30px; border: 2px; background: #2290E0;"/>
</div>
<div>
<img id="image1" src="img/111.jpg"/>
<img id="image2" src="img/222.jpg"/>
</div>
</div>
<script src="./js/jquery-1.8.3.min.js"></script>
<script src="./js/index.js"></script>
</body>
</html>jquery
须要注意的是:index.js使用“$”时,必需要引用“ <script src="./js/jquery-1.8.3.min.js"></script>”,要否则就会报 “Uncaught ReferenceError: $ is not defined”错误,若是引用的路径不对就会报:“Failed to load resource: net::ERR_FILE_NOT_FOUND”ide
第二步:编写index.js的代码,代码以下:htm