...

View Full Version : How to get char at current cursor position in textarea?



jerryhan
02-22-2003, 02:12 AM
Hi,
I'd like to know how to get the character at the current cursor position in the textarea. I am new to Javascript and I couldn't find this on the internet. Please help.

Thanks.

whammy
02-22-2003, 03:49 AM
Actually, I don't believe there is any way to do that, which is cross-browser, if it's even possible. I could be wrong though, I'm not one of the better javascript gurus here. ;)

I do recall quite a few posts dealing with this subject from the old forum though, if I remember right this isn't possible?

jkd
02-22-2003, 04:00 AM
In Gecko, this is trivial:

Assume the variable textBox is a reference to the textbox:

alert(textBox.value.charAt(textBox.selectionStart))

:)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum