I have following js:
<script>
function hadd(event,which){
var val = event.charCode;
if(val == 36){ //$ sign
var rh = $(which);
var cont = '<span class="dollar">Money</span>';
rh.append(cont); //????
}
};
</script>
<div class="example" contenteditable="true" tabindex="-1" onkeypress="hadd(event,this);">
Please insert (here) now
</div>
When "$" is typed, it appends new span at the end of "Please insert (here) now".
Please insert ($) now money.
How do I append the span right after where the $ was typed while removing the $ sign? (see below)
Please insert (money) now
$, it will be replaced with the wordmoney? Also, since there is parenthesis, it makes a confusion about what output you expect.