如何让这段JS 返回到 input 文本域里!

TianKongSkyWaWa 2013-08-21 08:27:37
<script type="text/javascript">
Date.prototype.format = function(format)
{
var o =
{
"M+" : this.getMonth()+1, //month
"d+" : this.getDate(), //day
"h+" : this.getHours(), //hour
"m+" : this.getMinutes(), //minute
"s+" : this.getSeconds(), //second
"q+" : Math.floor((this.getMonth()+3)/3), //quarter
"S" : this.getMilliseconds() //millisecond
}
if(/(y+)/.test(format))
format=format.replace(RegExp.$1,(this.getFullYear()+"").substr(4 - RegExp.$1.length));
for(var k in o)
if(new RegExp("("+ k +")").test(format))
format = format.replace(RegExp.$1,RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length));
return format;
}

var ddd = new Date();
document.write (ddd.format('yy-MM-dd hh:mm:ss'));
</script>



这段是JS获取年月日! 如何把ddd.format('yy-MM-dd hh:mm:ss') 返回到文本域里呢!
<input type="text" id="time" value="">
...全文
135 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
ghostkngiht 2013-08-23
  • 打赏
  • 举报
回复
document.getElementById('time').value = ddd.format('yy-MM-dd hh:mm:ss');
u010580980 2013-08-23
  • 打赏
  • 举报
回复
document.getElementById('time').value = ddd.format('yy-MM-dd hh:mm:ss'); jquery 这样 $("#time").val(ddd.format('yy-MM-dd hh:mm:ss'))
屌丝团 2013-08-23
  • 打赏
  • 举报
回复
引用 1 楼 ghostkngiht 的回复:
document.getElementById('time').value = ddd.format('yy-MM-dd hh:mm:ss');
+1 jquery 这样 $("#time").val(ddd.format('yy-MM-dd hh:mm:ss'));

51,409

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧