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
}
精彩评论