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>
  • 相关阅读:
    Linux下MongoDB的基本操作
    PHP curl及并发curl封装函数实现
    根据ip地址获取地区信息的接口
    修改Samba服务的监听端口
    定时脚本更新svn文件
    第一次直面http的301跳转
    ASP.NET MVC 学习之路-6
    ASP.NET MVC 学习之路-5
    C#静态构造函数
    HTML5新特性学习-2
  • 原文地址:https://www.cnblogs.com/dazhangli/p/5336208.html
Copyright © 2011-2022 走看看