简体   繁体   English

Javascript闭包:保存和还原文本

[英]Javascript Closures: Saving and Restoring Text

I am very new to javascript, and am to write a page that has a text area where a user can type in some text. 我对javascript很陌生,并且要编写一个页面,该页面具有一个文本区域,用户可以在其中键入一些文本。 The context needs to be stored in a local variable in a closure. 上下文需要存储在闭包中的局部变量中。 When this closure is called, the text area is reverted back to that saved state. 调用此闭包时,文本区域将恢复为该保存状态。 Also, when the user presses the "save" button, a new button appears that shows the timestamp of the saved data. 同样,当用户按下“保存”按钮时,会出现一个新按钮,显示已保存数据的时间戳。 When the button is pressed, the function for this save point is called, and the text is restored. 按下按钮后,将调用该保存点的功能,并还原文本。

I'm stumped on this.... and not sure where to start. 我对此感到困惑....并且不确定从哪里开始。 I have added a variable in a saveText function to store the input text. 我在saveText函数中添加了一个变量来存储输入文本。 Any help or direction would be much appreciated! 任何帮助或指示将不胜感激!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM