开发者

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

开发者 https://www.devze.com 2023-02-22 22:34 出处:网络
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?

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

精彩评论

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