Advertisement
Guest User

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

a guest
Feb 26th, 2012
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  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')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement