I have a little question
I want to click on my smileys and insert the text to the textarea. and when I want to add a smiley later, the smiley should be added to the
try also this...
$('#emoticons a').click(function() {
var smiley = $(this).attr('title');
var cursorIndex = $('#description').attr("selectionStart");
var lStr = $('#description').val().substr(0,cursorIndex);
var rStr = $('#description').val().substr(cursorIndex);
$('#description').val(lStr+" "+smiley+" "+rStr);
});
Fix after your comment:
$('#emoticons a').click(
function(){var smiley = $(this).attr('title');
var cursorIndex = $('#description').attr("selectionStart");
var lStr = $('#description').val().substr(0,cursorIndex) + " " + smiley + " ";
var rStr = $('#description').val().substr(cursorIndex);
$('#description').val(lStr+rStr);
$('#description').attr("selectionStart",lStr.length);
});