i got an inputfield with tag buttons. when i click on one of these buttons the value goes into the inputfield.
here is my code:
<input id="demooutput" type="text" size="15" value="My Text" name="demo" />
<span class="demooutput">
<a href="#" class="button orange"> A</a>
<a href="#" class="button orange"> B</a>
<a href="#" class="button orange"> C</a>
<a href="#" class="button orange"> D</a>
<a href="#" class="button orange"> E</a>
</span>
$('.demooutput a').click(function(){
$('#demooutput').val($('#demooutput').val() + ' ' + $(this).html());
return false;
});
is there a (short) way (with jQuery?) to add the value right where the mousecursor is?
Example: My input has the value My Text. When i put the cursor between My and Text and click a tag button the value goes to the and of Text. I want it exactly where the cursor is.
See a demo on JSFIDDLE