<divclass="fancy-div"onclick="fancyClick(this)"><divclass="fancy-content">
The things! 🐱🏍
</div><buttontype="button"class="fancy-button">
Click me
</button></div><divclass="fancy-div"onclick="fancyClick(this)"><divclass="fancy-content">
Cake 🎂
</div><buttontype="button"class="fancy-button">
Click me
</button></div><divclass="fancy-div"onclick="fancyClick(this)"><divclass="fancy-content">
Steamy 😤
</div><buttontype="button"class="fancy-button">
Click me
</button></div>
I love seeing raw JS solutions like this. Too much we get lost in frameworks and it's a good reminder.
I believe the weakness of this solution is its inaccessibility. For example there are no tabs on the clickable rows. Additionally, screen readers will not register that the divs are serving as buttons.
Scrolling through the page, it doesn't look like a button either. (I guess this is why I went straight to adding a hover effect).
Tabbable == fixable at least.
But I guess back to my original point: I tent to prototype the big idea in pure JS. And then move it to a framework or rewrite it as a reusable component where I can continue to work through enhancements like accessibility.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I would have gone with the Div approach.
If you can't do it in plain Js out of the box, it's probably not the best option. Unless it has some other benefit (like a lot less code).
jsfiddle.net/athomsfere/35wakz2j/1/
I love seeing raw JS solutions like this. Too much we get lost in frameworks and it's a good reminder.
I believe the weakness of this solution is its inaccessibility. For example there are no tabs on the clickable rows. Additionally, screen readers will not register that the divs are serving as buttons.
True, but I'd also say:
Scrolling through the page, it doesn't look like a button either. (I guess this is why I went straight to adding a hover effect).
Tabbable == fixable at least.
But I guess back to my original point: I tent to prototype the big idea in pure JS. And then move it to a framework or rewrite it as a reusable component where I can continue to work through enhancements like accessibility.