remove/restore elements, maintaining their events and element's children

Posted by Emin on Stack Overflow See other posts from Stack Overflow or by Emin
Published on 2010-05-25T09:41:22Z Indexed on 2010/05/25 10:21 UTC
Read the original article Hit count: 216

Filed under:
|

I came to a situation where I need to edit the following in a way that, on some event (lets assume the 'click' event in this case) I need to remove (or unwrap?) the .container and the .header and have the .itemlist still visible/available on the page. And then, I need to restore .container and .header back again on some other event, while still maintain the event listeners on the a tags, and if possible, without removing the said items from the DOM. Is this possible?

<ul class="container">
  <li class="header"><a href="#">delete</a> | <a href="#">edit</a></li>
    <ul class="itemlist">
       <li>some item</li>
       <li>some other item</li>
    </ul>
</ul>

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery