The core code is just this little bit.
The code is as follows |
Copy Code |
var log = []; $ (function () { var txt = window.setinterval (function () { if (Log[log.length-1]!= $ ("#t"). Val ()) { Log[log.length] = $ ("#t"). Val (); } }, 1500); var Isctrl = false; $ (document). KeyDown (function (e) { if (E.which = = 17) Isctrl = true; if (E.which = = && Isctrl = = True) { Log.pop (); $ ("#t"). Val (Log[log.length-1]). blur (); } }). KeyUp (function (e) { if (E.which = = 17) Isctrl = false; }); }); |
Complete instance
The code is as follows |
Copy Code |
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <title></title> <script src= "Http://z3f.me/js/jquery-1.6.2.min.js" type= "Text/javascript" ></script> <script type= "Text/javascript" > var log = []; $ (function () { var txt = window.setinterval (function () { if (Log[log.length-1]!= $ ("#t"). Val ()) { Log[log.length] = $ ("#t"). Val (); } }, 1500); var Isctrl = false; $ (document). KeyDown (function (e) { if (E.which = = 17) Isctrl = true; if (E.which = = && Isctrl = = True) { Log.pop (); $ ("#t"). Val (Log[log.length-1]). blur (); $ ("#s"). Val (Log[log.length-1]). blur (); } }). KeyUp (function (e) { if (E.which = = 17) Isctrl = false; }); }); Function Show () { $ ("#s"). Val (""); for (var i = 0; i < log.length; i++) { $ ("#s"). Val (log[i]+ "rn[" + i + "]rn-----------------------rn" +$ ("#s"). Val ()); } } </script> <body> <textarea id= "T" style= "width:400px; height:300px; " > </textarea> <button onclick= "Show ()" > Display history </button> <textarea id= "s" style= "width:400px; height:300px; " > </textarea> Press Ctrl+z to undo one step at a Exchange please add QQ 10590916 </body>
|