What is the best way to catch the last two letters typed in a text box? I need the last 2 characters that do not write the last two letters of the entire string. Appreciate the help! There is a demo of doing this with jQuery, while the last two characters were displayed which were displayed Were done: More Source: This demo captures the keypress event on the text area, cancels the value on the array (because then the number represents the number of the index key that is pressed because the key was pressed) and its Updating later display. Display updates just above the value of the array at the top of UPDATE Please see Tim Down's comment on my answer to see if there should be filtering Based on the quick trial in Chrome, my initial note was incorrect.
var key = []; $ ('# Target') Keypress (function (e) {keys.unshift (e.which); update ();}); Function Update () {$ ('# Last'). (': Eq (2)'). Remove ();} / Pre>
Pushes and removes the child (if any) list 2.
In addition, note that the way the jQuery code .keypress () Do not have to filter modifiers or arrow keys
Comments
Post a Comment