Posted By

zachharkey on 02/23/09


Tagged

textmate jquery drupal


Versions (?)

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


 / Published in: JavaScript
 

Thanks to James for this code.

  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  

You need to login to post a comment.