x-ref
x-ref in combination with $refs is a useful utility for easily accessing DOM elements directly. It's most useful as a replacement for APIs like getElementById and querySelector.
<button @click="$refs.text.remove()">Remove Text</button> <span x-ref="text">Hello 👋</span>
Hello 👋
Despite not being included in the above snippet,
x-refcannot be used if no parent element hasx-datadefined. → Read more aboutx-data
Ecosystem sponsor
Neon is a complete backend built around Lakebase Postgres, for developers, startups, and agent platforms, by Databricks.
neon.com →Code highlighting provided by Torchlight