I'm looking for a way to search and replace some word onclick (not all content). It's working only on predefined textarea. I want to run the script for the words I've just wrote.
<form action="#">
<textarea class="input" name="input" type="text" id="txt" />test</textarea>
<input type="button" value="Run" id="run"/>
</form>
$(document).ready(function() {
$('#run').click(function() {
var textarea=$('#txt');
textarea.html(textarea.html().replace(/test/g,"ok"));
});
});