1、首先到jQuery官网下载js库,网址为http://jquery.com/
2、建立一个jQuery示例的项目。
3、将js库放到jQuery示例的项目中。
4、写一个html页面
代码如下:
script>
Insert title here $(function(){
//setColor是鼠标移动的方法
$("li").mouseover(setColor).mouseout(setColor);
function setColor(){
//如果存在(不存在)就删除(添加)一个类
$(this).toggleClass("bg");
}
});
script>
横向菜单1 横向菜单2 横向菜单3 横向菜单4 横向菜单5 横向菜单6 5、运行效果图
下载本文