日期:2014-05-16 浏览次数:20420 次
?
//监听事件
function handler(event) {
??? ???? ??? ??? ?var index =event.data.index;
??? ???? ??? ??? ?var lis = $("#navul li ");
??? ???? ??? ??? ? $.each( lis, function(i, n){
??? ??? ??? ??? ??? if(i==index){
??? ???? ??? ??? ???? ??? $(this).addClass("ej_nav font-in");
??? ??? ??? ??? ??? }else
??? ??? ??? ??? ??? {
??? ???? ??? ??? ???? ??? $(this ).removeClass();
??? ??? ??? ??? ??? }
??? ???? ??? ??? });
??? ???? ??? }
??? ??? ??? //通过li的ID设置监听
??? ??? ??? $(function(){
??? ??? ??? ? var lis = $("#navul li a");
??? ??? ??? ? $.each( lis, function(i, n){
??? ??? ??? ??? $(this).bind("click", {index: i}, handler)
??? ??? ??? ??? });
??? ??? ??? });
?
?
jsp 内容
?
?
<ul id="navul">
??? ??? ??? ??? ??? ??? <li class="ej_nav font-in">
??? ??? ??? ??? ??? ??? ??? <a href="#"
??? ??? ??? ??? ??? ??? ??? ??? onClick="gotourl('url);"
??? ??? ??? ??? ??? ??? ??? ??? class="jc_nav_ico1" id="nav_gn">污染物限量</a>
??? ??? ??? ??? ??? ??? </li>
??? ??? ??? ??? ??? ??? <li >
??? ??? ??? ??? ??? ??? ??? <a href="#"
??? ??? ??? ??? ??? ??? ??? ??? onClick="gotourl('url');"
??? ??? ??? ??? ??? ??? ??? ??? class="jc_nav_ico1" id="bz_gj">真菌毒素限量</a>
??? ??? ??? ??? ??? ??? </li>
??? ??? ??? ??? ??? ??? <li >
??? ??? ??? ??? ??? ??? ??? <a href="#"
??? ??? ??? ??? ??? ??? ??? ??? onClick="gotourl('url');"
??? ??? ??? ??? ??? ??? ??? ??? class="jc_nav_ico1" id="nav_cyzb">农药残留限量</a>
??? ??? ??? ??? ??? ??? </li>