1、首先到j(luò)Query官網(wǎng)下載js庫(kù),網(wǎng)址為
2、建立一個(gè)jQuery示例的項(xiàng)目。
3、將js庫(kù)放到j(luò)Query示例的項(xiàng)目中。
4、寫一個(gè)html頁面
復(fù)制代碼 代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="author" content="Kong.Yee"/>
<meta http-equiv="corporation" content="廣州匡興軟件科技有限公司"/>
<meta http-equiv="contact" content="791663094或kong.yee@foxmail.com"/>
<script type="text/javascript" language="JavaScript" src="js/jquery-1.10.2.js"></script>
<title>Insert title here</title>
<style type="text/css">
.bg{
/*背景顏色*/
background: #f00;
/*字體顏色*/
color: #fff;
width: 80px;
}
ul, li {
/*清除ul和li上默認(rèn)的小圓點(diǎn)*/
list-style: none;
}
ul {
/*清除子菜單的縮進(jìn)值*/
padding: 0;/*IE8,IE9,火狐可以;IE7,IE6,IE5.5不行*/
margin: 0;/*都可以了*/
}
</style>
<script type="text/javascript">
$(function(){
//setColor是鼠標(biāo)移動(dòng)的方法
$("li").mouseover(setColor).mouseout(setColor);
function setColor(){
//如果存在(不存在)就刪除(添加)一個(gè)類
$(this).toggleClass("bg");
}
});
</script>
</head>
<body>
<div>
<ul>
<li>橫向菜單1</li>
<li>橫向菜單2</li>
<li>橫向菜單3</li>
<li>橫向菜單4</li>
<li>橫向菜單5</li>
<li>橫向菜單6</li>
</ul>
</div>
</body>
</html>
新聞熱點(diǎn)
疑難解答
圖片精選