How to close Dropdown when user click on one item? #1870
Answered
by
fini
MiladDevarts
asked this question in
Q&A
-
hey Guys! |
Beta Was this translation helpful? Give feedback.
Answered by
fini
Jun 1, 2023
Replies: 2 comments 4 replies
-
If Using Method 1 from the docs (
|
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
saadeghi
-
In svelte you can do it like this <script lang="ts">
let openDropdown: boolean = false
function handleClickItem() {
// close it
openDropdown = false
}
</script>
<details class="dropdown" bind:open="{openDropdown}">
<summary class="m-1 btn">open or close</summary>
<ul class="p-2 shadow menu dropdown-content z-[1] bg-base-100 rounded-box w-52">
<li>
<a on:click={handleClickItem}>Item 1</a>
</li>
<li>
<a on:click={handleClickItem}>Item 2</a>
</li>
</ul>
</details> |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If Using Method 1 from the docs (
<details>
tag):