...

/

Set the Content of Elements: x-text and x-html

Set the Content of Elements: x-text and x-html

Learn to manipulate the text content of HTML elements with x-text and to append HTML content to an element with x-html.

We'll cover the following...

The x-text directive

There are times we may want to set the text content of an HTML element. AlpineJS allows us to do this using the x-text directive.

Consider the example below from the “Hello Alpine” program:

  • HTML
html
Setting h1 text content with x-text

Line 7 ...