" emulate the click on the same word at the same point in the textarea "
I guess its difficult to capture the exact position of the text in textarea, but you can do some thing below ( though it doesn't met your requirement ) . please Try to understand.
I feel this is difficult 'cause, just clicking on some text in a <div />
tag doesn't give the offset position of the Word. If you're going to select some text in div, may be this post helps.
But I'd like to learn if it is possible using just a .click()
If some one comes up with a cool thought, it would be more helpful =)
HTML :
<!DOCTYPE html>
<html>
<head>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<meta charset=utf-8 />
<title>Avinash</title>
<style>
#input , #output { margin: 20px;width:300px;height:200px; border:1px solid #000; font 15px Arial; }
#output {overflow:scroll;float:left; font:bold 14px verdana; color : #0099b9; }
</style>
</head>
<body>
<table>
<tr>
<td>
<textarea id="input" >Type your Text </textarea>
</td>
<td>
<div id="output" > </div>
</td>
</tr>
</table>
</span>
</body>
</html>
JavaScript :
$(function() {
$('#input').one('focus',function() {
$(this).val('');
}).bind('keyup',function() {
$('#output').text($(this).val());
});
$('#output').bind('click',function() {
alert('focusing Textarea');
$('#input').focus();
});
});
you can Test the above Code here : http://jsbin.com/atuqo4