Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1541

Toggle visibillity of a list in Svelte

$
0
0

I am trying to do the most basic thing in Svelte but I keep failing. I want the button element to trigger the visibillity of the ul-element with classname "this-one". I am stuck in the "vanilla js"-approach and can not wrap my head around how to achieve this the svelte-way. Any pointers?

<ul>    {#each item.children as child (child.id)}<li><div><a href={child.route.path}                   on:click={() => dispatch('click')}><span>{child.name}</span></a>                {#if child.children?.length > 0}<button><i class="chevron-down"></i></button>                {/if}</div>            {#if child.children?.length > 0}<ul class="this-one">                    {#each child.children as grandChild}<li><a href={grandChild.route.path}                               on:click={() => dispatch('click')}>                                {grandChild.name}</a></li>                    {/each}</ul>            {/if}</li>    {/each}</ul>

Viewing all articles
Browse latest Browse all 1541

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>