Pushing elements into array as copy
- by koko
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 }); });