0

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.

user2014429
  • 2,497
  • 10
  • 35
  • 49
  • try the answer to this question: http://stackoverflow.com/questions/2897155/get-cursor-position-within-an-text-input-field then use substr – Adam Sep 13 '13 at 11:57
  • Thanks for the link, it was helpful, I will take some time to study the answers – user2014429 Sep 13 '13 at 12:05

0 Answers0