I was researching but I don't have a way to solve this problem:
I would like to drag & drop the data from <div> tag to <textarea> tag with value in <textarea> will be change follow to position, where I drop the <div> tag.
Example: value1 -> I drag <div class="btn btn-info draggable">value1</div> to <textarea>Type something</textarea> -> change to <textarea> Type value1 something</textarea>
This is my current code:
$(document).ready(function () {
$(".draggable").draggable({
revert: true,
helper: 'clone',
start: function (event, ui) {
$(this).fadeTo('fast', 0.5);
},
stop: function (event, ui) {
$(this).fadeTo(0, 1);
}
});
$("#MessageArea").droppable({
hoverClass: 'active',
drop: function (event, ui) {
this.value += " *" + $(ui.draggable).text() + "* ";
},
});
});
<fieldset>
<legend>Data Area</legend>
<div class="btn btn-info draggable">value1</div>
<div class="btn btn-info draggable">value2</div>
</fieldset>
<br />
<div class="form-group">
<textarea id="MessageArea">Type something</textarea>
<br />
<input type="button" class="btn btn-warning" value="CLEAR" onclick="$('#MessageArea').val('');" />
</div>