全選才可以提交

HTML代碼如下:

<div class="gas">
        <i class="iconfont icon-qititance"></i>
        <p class="makeupGas">補充氣體儲存量</p>
        <i class="iconfont">&#xe612;</i>
 </div>
 <div class="gas">
         <i class="iconfont icon-guandaoshutong"></i>
         <p class="pipelineMaintenance">水管已經維修</p>
         <i class="iconfont">&#xe612;</i>
 </div>

js代碼如下:

$('.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;}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章