开发者

How to replace the content of the active text field with the current date?

How do I replace the content of the current (i.e. active, with the curso开发者_开发百科r in it) text input field with the current date? or with any specified text?

Thanks for your help :)


var element = document.activeElement;//gets selected element
if(element.tagName === "INPUT"){
  element.value = new Date().toUTCString();//changes text in input element to today's date
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜