jquery 查找元素,並判斷隱藏或顯示


html

                                    <div class="panel-heading">
                                        <h4 class="panel-title">
                                            <a data-toggle="collapse" data-parent="#accordion"
                                               href="#collapseOne" >
                                                一人有限公司
                                            </a> <label ><input type="checkbox" class="ace " id="allcheck"/>
                                                <span class="lbl"></span> 全選
                                            </label>
                                        </h4>
                                    </div>
<style>
.hide{
display:none;
}
</style>
 

js

 
         
$("#accordion a").on('click',function () {
display = $(this).next('label').css('display');
if(display == 'none'){
$(this).next('label').removeClass("hide");//注意不要使用display:inline-block等,使用的話后面的label會換行

}else{
$(this).next('label').addClass("hide");
}
}
 
        

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM