In prototypejs, why does the following code remove the matching divs from the #test div?
What confuses me is that this happens when they are being inserted in the #droparea, and not when they are being pushed in the array.
<div id="test">
<div class="foo" id="22.1234">
1
</div>
<div class="foo" id="22.1235">
2
</div>
<div class="foo" id="53.2345">
3
</div>
<div class="foo" id="53.2346">
4
</div>
</div>
<div id="droparea">
</div>
js
var elArray = [];
var els = $('test').select('.foo');
els.each(function(x){ if(x.id.split('.')[0] == 22){ elArray.push(x); } });
elArray.each(function(y){ $('droparea').insert({ bottom: y }); });
I take it you want to copy/clone the elements into the drop area, not move them?
This thread on Google Groups discusses how to clone an element. Note in particular the caveats about changing the ID before reinserting to the document.