Move div.admin-links into the next adjacent sibling div.block


/ Published in: JavaScript
Save to your folder(s)

Thanks to [James](
http://www.girsbrain.org/blog
) for this code.


Copy this code and paste it in your HTML
  1. $(document).ready(function() {
  2.  
  3. // Take all divs that match class .admin-links and move them inside of
  4. // the next adjacent sibling div with class .block.
  5. var $blocks = $(".block");
  6. $blocks.each(function() {
  7. var $block = $(this);
  8. var $admin = $(this).prev();
  9.  
  10. if (!$admin.hasClass("admin-links"))
  11. return $block;
  12.  
  13. var $copy = $admin.clone(true);
  14. $admin.remove();
  15. $copy.prependTo($block);
  16. });
  17. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.