Search code examples
hyperscript

Make a clone of html element in _hyperscript


How to make a clone of html element in _hyperscript?

For example, I want to see a copy of a button after clicking on it. Something like:

<button _="on click put me after me">Test</button>

Solution

  • If you want the hyperscript to work for new nodes I currently do something like this:

    <div id="test123">
       <div _="on click log 'Test' then put my outerHTML after me 
           _hyperscript.processNode(#test123)">Copy Me</div>
    </div>