Basically this question is pretty similar to:
Insert value into TEXTAREA where cursor was
JSFiddle: http://jsfiddle.net/rQXrJ/1/
The thing is, I can't get it to work for multiple textareas.
I've tried multiple combinations of things but still no success:
1)
$("#foo-1").click(function () {
$textBox = $(this);
$textBox.focusout(saveSelection);
});
$("#foo-2").click(function () {
$textBox = $(this);
$textBox.focusout(saveSelection);
});
2)
function changeTextBox(newID) {
var fullID = "#" + newID;
$textBox = $(newID);
$textBox.focusout(saveSelection);
}
$(".txt").click(function () {
var id = $(this).attr("id");
changeTextBox(id);
});
Here's my jsFiddle: https://jsfiddle.net/yneco5ft/