Want more features on Pastebin? Sign Up, it's FREE!
Guest

Using jQuery to remove a second form element without losing the child elements

By: a guest on Feb 26th, 2012  |  syntax: None  |  size: 0.62 KB  |  views: 34  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. // Captures the children
  2.             var children = $("form:eq(1)").children();
  3.             // Removes the form
  4.             $("form:eq(1)").remove();
  5.             // append the child elements back into the DOM
  6.             $("#fillDiv").append(children);
  7.        
  8. // grab the child nodes
  9. var children = $('#badForm').children();
  10. // or var children = $('#badForm > *');
  11.  
  12. // move them to the body
  13. $(body).append(children);
  14.  
  15. // remove the form
  16. $('#badForm').remove();
  17.        
  18. $.ajax({
  19.     type: "get",
  20.     url: "url",
  21.     data: ,
  22.     cache: false,
  23.     success: function(data){
  24.  
  25.     }
  26. });
  27.        
  28. $(data).find('#whatYouNeed').appendTo('#whereYouNeed')
clone this paste RAW Paste Data