please see the code .
$(".test").on("click", function() {
var sclass = $(this).attr("class").split(" ")[1];
$(".color").trigger("click");
$(".color").on("change", function() {
var scolor = $(this).val();
$("." + sclass).css("background-color", scolor);
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<input type="color" name="color" class="color"><br><br>
<div class="test test1">hii</div><br><br>
<div class="test test2">hello</div>
here i need to change the background color of the div by selecting color . But when i am selecting color for one div then this color is effected to two ? what is the error in this code ?