HTML代碼如下:
<div class="gas"> <i class="iconfont icon-qititance"></i> <p class="makeupGas">補充氣體儲存量</p> <i class="iconfont"></i> </div> <div class="gas"> <i class="iconfont icon-guandaoshutong"></i> <p class="pjs代碼如下:$('.gas i:last-child').on("click",function(){ $(this).toggleClass('color');//判斷是否有color,如果沒有就加上,有就刪除 for(var i = 0; i < $('.gas i:last-child').length; i ++){ if(!$('.gas i:last-child').eq(i).hasClass('color')){ state = 1; $('.finish').addClass('disabled'); break; } } if(i == $('.gas i:last-child').length){ state = 0; $('.finish').removeClass('disabled'); }})在CSS代碼里要有一個color{color:green;}
新聞熱點
疑難解答