...

/

Loop through a List: x-for

Loop through a List: x-for

Learn to create DOM elements from a list using x-for.

If we want to attach a list of elements to a node based on some data, we can easily handle that in JavaScript. Since AlpineJS comes to simplify some use cases of JavaScript, it provides an x-for directive to create a list of DOM elements.

The x-for directive allows us to iterate through a list and create DOM elements from them. We’ll rewrite the first example of ...