layui 单选框取消选中


<ul>
                                                                <li>
                                            <span class="time">17:18</span>
                                            <span class="type">内勤</span>
                                            <span class="address" dataid="1535562000194261055">广东省广州市天河区五山路靠近金山大厦(五山路)</span>
                                            <input data-check="false" lay-filter="jiedian" id="1" type="radio" name="companyName" value="广东省广州市天河区五山路靠近金山大厦(五山路)">
                                            <label for="1"></label>
                                        </li>
                                        <li>
                                            <span class="time">13:08</span>
                                            <span class="type">内勤</span>
                                            <span class="address" dataid="1535562000194264261">广东省广州市天河区翰景路250号靠近广州天河软件金山园区</span>
                                            <input data-check="false" lay-filter="jiedian" id="2" type="radio" name="companyName" value="广东省广州市天河区翰景路250号靠近广州天河软件金山园区">
                                            <label for="2"></label>
                                        </li>
                                        
                                    
                                    

                    </ul>

关键代码
$(this).prop('checked', false);
layui.form.render();
用自定义属性 data-check来判读是第是否第二次点击


        // 再次点击取消选中
  
        $('.t-body input').on('click',function () {
           var xuanzhong = $(this).attr('data-check');
           if(xuanzhong == "false"){
                $('.t-body input').each(function (i, input) {
                   $(input).attr('data-check', "false");
               })
               $(this).attr('data-check', "true");
                $(this).prop('checked', true);
               layui.form.render(); 
           } else{
               $('.t-body input').each(function (i,input) {
                   $(input).attr('data-check', "false");
               })
                $(this).prop('checked', false);
               layui.form.render(); 
           }

        })


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM