Hi there
I'm using jquery to get the last word in a string, but i want to be sure it is the best way (performance wise), because the string could get very long
furthermore, i want to add capability to get the "current" word, which may not simply be the last word..
This is my code so far
<script type="text/javascript">
function lookup()
{
var s = $('#text').val().split( " " ).pop();
if(!s.length)
return false;
$('#output').html('"'+s+'"');
}
</script>
<div id="main">
<textarea id="text" rows="5" cols="50" onkeyup="lookup(this.value);">
</textarea>
<div id="output"></div>
</div>
any tips on how i can get it to handle more than just the "last" word, ie, if i move the cursor back a few words to another word, can i still somehow get the current position & then get that word?