This question already has an answer here:

I am trying to determine the last character of a string in a text input field, but ignoring any characters to the right of the cursor. Essentially I want to determine the the character directly left of the cursor. So far I can only get characters based on there position within the string like this:

var str = $('#tBox').val();
var lastChar = str.charAt(str.length-1 );

<input type = "text" id = "tBox">

is what I'm asking possible? Thank you.

marked as duplicate by dtech, Josh Mein, Kartik Domadiya, nmaier, Olaf Sep 13 '13 at 14:04


Browse other questions tagged or ask your own question.