Alpine.js
$root & $el
$root
$root is a magic property that can be used to retrieve the root element of any Alpine component. In other words the closest element up the DOM tree that contains x-data.
<div x-data data-message="Hello World!">
<button @click="alert($root.dataset.message)">Say Hi</button>
</div>
$el
$el is a magic property that can be used to retrieve the current DOM node.
<button @click="$el.innerHTML = 'Hello World!'">
Replace me with "Hello World!"
</button>
$data
$data is a magic property that gives you access to the current Alpine data scope (generally provided by x-data).
$refs
$refs is a magic property that can be used to retrieve DOM elements marked with x-ref inside the component. This is useful when you need to manually manipulate DOM elements. It's often used as a more succinct, scoped, alternative to document.querySelector.
