0

I have a div that I've selected in jQuery and it has div's preceding it. I want to select all of them, copy them to AFTER the selected div and delete them from their original location.

Shamoon
  • 38,429
  • 77
  • 269
  • 518

2 Answers2

3
var selected = $('#selected');
selected
    .prevAll()
    .insertAfter(selected);
Jacob
  • 75,331
  • 23
  • 142
  • 223
0

Would it not be easier to move the selected div to the front of the others?

$('#selected_div').insertBefore($('#selected_div').siblings('div:first'));
Blair McMillan
  • 5,289
  • 2
  • 24
  • 44