This is my first time using svelte. I am also using tailwind and astro butthatbut that is irrelevant. The following component prepends ">> ">> to my text when it is being hovered upon and takes the ">> ">> out when it is not.
Is this the typical way to use svelte, am? Am I doing something wrong—becausewrong? I feel I am?.
<script>
let spanId = "selected";
let isMouseOver = false;
function handleMouseOver() {
if(!isMouseOver) {
this.innerHTML = `<span id="${spanId}">>> </span>` + this.innerHTML;
isMouseOver = true;
}
}
function handleMouseOut() {
let selectedSpan = document.getElementById(spanId);
selectedSpan.parentNode.removeChild(selectedSpan);
isMouseOver = false;
}
</script>
<p
class="hover:text-green-600 cursor-pointer whitespace-nowrap"
on:mouseover={handleMouseOver}
on:mouseout={handleMouseOut}
>
<slot />
</p>
```