欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

html jquery li标签 选中

程序员文章站 2022-03-08 12:01:29
...



$('.j-d-list').find($('li[data-m="2017-10"]'))
  var current=$("#diss").find($("dd[class='current']"));
  
  
  ----------------------------------------------------------------------------------------
  
  class="current"
  
   var current=$("#workplaceSelect").find($("a[class='current']"));
         alert(current); alert(current.attr("districtId"));
		 //选中一个,移除其它。始终就一个选中 <ul> <li class="current"> </li>  <li> </li>  </ul>
		 this.addClass('current').siblings().removeClass("current");
		 
		 $('.j-d-list').find($('li[data-m="'+switchMonth+'"]')).removeClass('on').addClass('off').find('i').text('');
		 
		 
		 $("#workplaceSelect a").each(function(){$(this).attr("class","")});
		 
		 
--------------------------jquery-------以下调试ok代码--------------当前操作a标签加样式 选中状态 -----------------------------------------		 
		   
		   html代码
		   
		   <ul id="workplaceSelect">
<li  >
  <a href="#"  districtId='1' onclick="goPage(this,1)" > 1<i>预约</i>  </a>
</li>
<li  >

<a href="#"  districtId='2' onclick="goPage(this,2)" > 2<i>预约</i>  </a>

</li>
<li >
<a href="#"  districtId='3' onclick="goPage(this,3)" >
3<i>预约</i></li>   </a>

</ul>



		 <javascript>
		   //获得点击选中的 属性 districtId 值 
		  function goPage(data,type){
         //alert($(data).attr("districtId"));
		  //设置所有workplaceSelect 下的 a标签 class为""  ,不选中状态
          $("#workplaceSelect a").each(function(){$(this).attr("class","")});
		  //当前点击a标签加class="current"
         $(data).addClass('current').siblings().removeClass("current");
        // $(data).attr('class','current');//.siblings().removeClass("current");
		 //获得当前选中 workplaceSelect a标签current属性上的districtId 值
         var current=$("#workplaceSelect").find($("a[class='current']"));
         alert(current); alert(current.attr("districtId"));
		var districtId =current.attr("districtId");
        // alert(id);
        // window.location.href='http://localhost:8080/positionInfoAndCompany/list?districtId='+districtId;
		
		   }
		   
		  </javascript>  
        

相关标签: jquery

上一篇: java拼接JSON串

下一篇: git相关