I am interested in changing the toggleClass depending on what is clicked on.
I want the class to be dependent on the previous click on the page.
So If I click on Letter "A" - in this case it will make the square red. Upon clicking on the square I want the .toggleClass to be .darkred
When I click on the Letter "B" - I want the .toggleClass to be .darkblue
how can i make it dynamic so it knows which class to add to the toggleClass
<script>
$("li.alpha").click(function(){
$(".color").addClass("red").removeClass("blue").removeClass("orange");
});
$("li.bravo").click(function(){
$(".color").addClass("blue").removeClass("red").removeClass("orange");
});
$("li.charlie").click(function(){
$(".color").addClass("orange").removeClass("blue").removeClass("red");
});
</script>
<script>
$(".color").on("mousedown mouseup", function(e)
{
$(".color").toggleClass("darkblue"); // I want this class to be dynamic. It should be based on what I clicked on. so in this case I would have clicked on li.bravo
});
</script>
I want the class added in the .toggleClass to be dynamic and based on the class I am adding.
red = .darkred
blue = .darkblue
orange = .darkorange.