Qwik event that triggers when the element is initialized

103 Views Asked by At

I want to get an element. The quickest way to do that seems to be through event.target. So I want an event that is triggered as soon as an element is initialized, and then never again

Something like this

<div
onInit$={(e)=>{
  // do stuff with e.target
}}></div>

I've tried onLoad$ and onComplete$, niether of which did what you would expect them to. Also onDomContentLoaded isnt a thing

1

There are 1 best solutions below

0
On

You could use useVisibleTask for triggering a function when the component is rendered in the client side

https://qwik.builder.io/docs/components/tasks/#usevisibletask