_hyperscript
_hyperscript copied to clipboard
"If" functionality which remove/add element from the DOM
I would like to replicate the ngIf directive from Angular in hyperscript.
To do that I need to remove or add from DOM elements based on a condition.
But I didn't find a manner with hyperscript currently.
Here an example code to begin with :
<div _="set global currentItem to 0">
<div **for loop with index **>
<div class="element**index**"">
<p>Hello world</p>
</div>
</div>
<button _="on click show :currentItem and remove others then halt the event">
</div>
The idea is to hide/show (by removing or adding) element depending its index. If the index is equal tu currentItem it shows the element otherwise it is removing it.