點擊checkbox,觸發事件


時間選擇:
起始時間:<input  type="text" value="2016-03-21 12:24:10" id="starttime"  size="" class="m-wrap wid200 " onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})">
結束時間:<input type="text" value="2017-03-21 12:24:10" size="" class="m-wrap wid200 " id="startime1" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})">
checkbox復選框: <input type="checkbox" value="" style="opacity: 0;" id="callever" name="callever">
<script>
//        區域報警設置的是否每天報警的時間不可選擇的js        
$(function(){
    $("#callever").change(function(){
        if($("#callever").prop("checked")){           //prop()函數用於設置或返回當前jQuery對象所匹配的元素的屬性值,復選框被選中時
             $("#starttime").attr('readonly','readonly');  //時間input文本添加屬性值 
            document.getElementById("starttime").style.color='rgb(173, 173, 173)';
             document.getElementById("starttime").onclick=function(){};
            $("#startime1").attr('readonly','readonly');
            document.getElementById("startime1").style.color='rgb(173, 173, 173)';
             document.getElementById("startime1").onclick=function(){};
                
        }else{
            document.getElementById("starttime").style.color='rgb(63, 63, 63)';
            document.getElementById("startime1").style.color='rgb(63, 63, 63)';
             $("#starttime").removeAttr('readonly','');
             $("#startime1").removeAttr('readonly','');
              document.getElementById("starttime").onclick=function(){laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})};
               document.getElementById("startime1").onclick=function(){laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})};
        }
    })
})


    </script>

 


免責聲明!

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



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