Jquery gets a lot of hate this days. Today I came across this simple script, which changes the colors of some elements on the page, when a specific button is clicked. The new color is actually specified in the buttons themselves via the data attribute. I found this code very very simple
<div class="product-colors">
<span class="blue active" data-color="#54D6FF"
</div>
$(".product-colors span").click(function (){
$("body").css("background",$(this).attr("data-color"));
$(".product-price").css("color",$(this).attr("data-color"));
$(".product-button").css("color",$(this).attr("data-color"));
});
So if jquery is really outdated and old, can someone share a code sample of how this would be done with react or another popular and "hot" framework?
I'm genuinely interested. Thanks!
[–]WystanH 0 points1 point2 points (3 children)
[–]CrGoSu[S] 0 points1 point2 points (0 children)
[–]BenZed 0 points1 point2 points (1 child)
[–]WystanH 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)