zoukankan      html  css  js  c++  java
  • 点击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>
  • 相关阅读:
    yum命令速查
    5分钟理解编译系统
    Nginx(一)安装及启停
    Linux时间命令
    常用七种排序的python实现
    python迭代器、生成器、装饰器
    LeetCode【第217题】Contains Duplicate
    LeetCode【第1题】Two Sum
    python【第二十篇】Django表的多对多、Ajax
    不要问我DO在哪里?
  • 原文地址:https://www.cnblogs.com/dazhangli/p/5336208.html
Copyright © 2011-2022 走看看