これを行うための拡張可能な方法が必要だと仮定すると...
<div id="area" class="movable">I wish I could go down there</div>
<div id="area2" class="movable">Me too please!!</div>
</br>
<input type="textarea" id="displayarea" class="inputtable" value="" />
<input type="textarea" id="displayarea2" class="inputtable" value="" />
</br>
<div id="submit">click me</div>
</br>
$('div#submit').click(function(e) {
$('input.inputtable').each(function() {
var input = $(this);
$('div.movable').each(function() {
var self = $(this);
if (!self.hasClass('moved') && !input.hasClass('inputted')) {
input.val(self.text()).addClass('inputted');
self.addClass('moved');
}
});
$('div.movable.moved').detach(); //safe to remove now that we're not looping through them.
});
e.preventDefault();
return false;
});
作業フィドル: https://jsfiddle.net/EzkFR/10/