- $('#headerLi li a').bind({
- 'mouseover' : function(){
- //获取当前元素的索引值
- int = $(this).index();
-
- //执行函数,这里会显示右侧的第一个div元素
- //divShow(int);
- $(this).html();
- $.session.set("inner", $(this).html());
-
- },
- 'mouseout' : function(){
- //鼠标划开时的操作
- //int = 0;
- //divShow(int);
- alert($.session.get("innner");
- }
- });
复制代码 为所有li绑定事件
简介:
JquerySession是一个基于jquery的用来处理session的库,使用它可以简化我们的工作。在使用之前需要引入jquery。 语法:
添加数据
$.session.set('key', 'value') 删除数据
$.session.remove('key'); 获取数据
$.session.get('key'); 清除数据
$.session.clear(); 下载JquerySession
JQ多事件绑定,html和JQ如下: Html - <UL id=headerLi class=ul1>
- <LI><A href="index.php">首页</A> </LI>
- <LI><A href="about.php?id=239">关于我们</A> </LI>
- <LI><A href="news.php?id=个股分析">个股分析</A> </LI>
- <LI><A href="news.php?id=大盘观点">大盘观点</A> </LI>
- <LI><A href="news.php?id=操盘手">操盘手</A> </LI>
- </ul>
复制代码 JQ
- $('#headerLi li').bind({
- onclick : function(){
- //获取导航中的li对应的名称 存入 session
- $.session.set("a_val", $(this).html());
- alert($.session.get("a_val"));
- },
- mouseover : function(){
- //设置样式
- //alert("mouseover");
- $(this).css("background-color","red");
- $(this).find("a").css("color","#FFF");
- $(this).find("a").css("text-decoration","none");
-
- },
- mouseleave : function(){
- //鼠标划开时的操作
- //alert($.session.get("a_val"));
- $(this).css("background-color","");
- }
- });
-
复制代码
|