DEV Community

Discussion on: Fancy a modern alternative to jQuery? Meet AlpineJS

Collapse
 
semirteskeredzic profile image
Semir Teskeredzic

Hey @baz94 thanks for the comment. Yes, that is the beauty of it, it is HTML powered by interactivity that JavaScript provides.
In my opinion it is much more readable to have methods and directives present right in the HTML element. It gives your HTML elements reactivity and interactivity with much more readable and modern code than jQuery selectors and event handlers. That said it is the same problem but solution is done in a better way.

Perhaps I didn't quite get what you wanted to say with the 'out of the box' sentence but essentially you said that you can do pure HTML without any JS to handle for example onClick events out of the box? Please, I'd love to see that code.

Once again thanks for the comment.

Collapse
 
moopet profile image
Ben Sinclair

This HTML snippet:

<details>
  <summary>I am the title</summary>
  <p>I am hidden until the title is clicked</p>
</details>
Enter fullscreen mode Exit fullscreen mode

will do what you're using Javascript to achieve, won't it?
I mean, I'm sure there are a lot of things that this library does that you can't do in plain old HTML, but that's not one of them. Could you give an example where it does something you can't do in HTML?