HTML:
<!--引入WdaePicker文件--> <script type="test/javascript" scr="datePicker/WdatePicker.js"></script> <link rel="stylesheet" type="text/css" href="datePicker/skin/WdatePicker.css"/> <input id="time" type="text" class="Wdate" onclick="WdatePicker({el:$dp.$(‘time‘),dateFmt:‘yyyy-MM-DD‘,onpicked: function () { alert(123) } })"/>//onpicked: function () { alert(123) } 就是选择日期完毕触发事件
JS:
$dp.$(‘time‘).value=getNowFormatDate() ; //设置初始值为当前时间 var time = $dp.$(‘time‘).value; //获取值,$dp.$(‘time‘)相当于Document.GetElementById 上面使用到的getNowFormatDate() 方法: //获取当前时间,格式YYYY-MM-DD function getNowFormatDate() { var date = new Date(); var seperator1 = "-"; var year = date.getFullYear(); var month = date.getMonth() + 1; var strDate = date.getDate(); if (month >= 1 && month <= 9) { month = "0" + month; } if (strDate >= 0 && strDate <= 9) { strDate = "0" + strDate; } var currentdate = year + seperator1 + month + seperator1 + strDate; return currentdate; }
原文地址:https://www.cnblogs.com/wangxiaoyan/p/9361572.html
时间: 2024-10-24 06:07:44