Just a heads up before I ask my question - the code I'm about to share is sourced from this video on YouTube, so all credit goes to the creator.
JS
$(".product-colors span").click(function(){
$(".product-colors span").removeClass("active");
$(this).addClass("active");
$("body").css("background",$(this).attr("data-color"));
$(".product-price").css("color",$(this).attr("data-color"));
$(".product-button").css("color",$(this).attr("data-color"));
$(".product-pic").css("background-image",$(this).attr("data-pic"));
});
HTML
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="style.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" charset="utf-8"></script>
</head>
<body>
<div class="product-card">
<h1>Title</h1>
<p>Thing<p>
<div class="product-pic"></div>
<div class="product-colors">
<span class="blue active" data-color="#7ed6df" data-pic="url(1.png)"></span>
<span class="green" data-color="#badc58" data-pic="url(2.png)"></span>
<span class="yellow" data-color="#f9ca24" data-pic="url(3.png)"></span>
<span class="rose" data-color="#ff7979" data-pic="url(4.png)"></span>
</div>
<div class="product-info">
<div class="product-price">1.000.000$ </div>
<a href="#" class="product-button">BUY</a>
</div>
</div>
</body>
</html>
$(".product-colors span").click(function() {
$(".product-colors span").removeClass("active");
$(this).addClass("active");
$("body").css("background", $(this).attr("data-color"));
$(".product-price").css("color", $(this).attr("data-color"));
$(".product-button").css("color", $(this).attr("data-color"));
$(".product-pic").css("background-image", $(this).attr("data-pic"));
});
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="style.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
<div class="product-card">
<h1>Title</h1>
<p>Thing
<p>
<div class="product-pic"></div>
<div class="product-colors">
<span class="blue active" data-color="#7ed6df" data-pic="url(1.png)"></span>
<span class="green" data-color="#badc58" data-pic="url(2.png)"></span>
<span class="yellow" data-color="#f9ca24" data-pic="url(3.png)"></span>
<span class="rose" data-color="#ff7979" data-pic="url(4.png)"></span>
</div>
<div class="product-info">
<div class="product-price">1.000.000$ </div>
<a href="#" class="product-button">BUY</a>
</div>
</div>
</body>
</html>
I'm looking to change the hover effect of the "product-button" when clicked and change its background, but being new to HTML/CSS, I'm unsure how to do it. Upon researching, I've learned that jQuery is considered outdated - can JavaScript be used instead? Any help would be appreciated. Thank you!