Native JS to achieve message board function

The example of this article shared JS to implement the specific code of the message board function, for the reference, the specific content is as follows

Implementing this message board function, so the top renderings:

原生JS实现留言板功能

Implement the user message content, the message is specifically time.

 Window.onLoad = function () {var OmessageBox = document.getlementByid ("MessageBox"); var oinput = document.getlementByid ("MyInput"); Var opostbtn = document.getlementByid ("dopost"); opostbtn.onclick = function () {if (oinput.value) {// Write a message Time VAR OTIME = Document.createElement ("DIV"); otime.classname = "time"; var myDate = new Date (); oTime.innerHTML = myDate.toLocaleString (); oMessageBox.appendChild (oTime); // write message var oMessageContent = document.createElement ( "div"); oMessageContent. ClassName = "Message_Content"; OMESSAGECONTENT.INNERHTML = OINPUT.VALUE; ONPUT.VALUE = ""; OMESSAGEBOX.APPENDCHILD (OMESSAGECONTENT);}}}    By obtaining the input focus event capture content of the INPUT, the DIV of the message board is passed to the message board.  
User Message

  Submit  
The above is all the contents of this article, I hope to help everyone's learning, I hope everyone supports Tumi Cloud.
© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment