I am trying to implement an option to select / deselect a drawing (each drawing would be a product). And I got it from the start, I can do it one by one, or through a button that selects or deselects everything.
The problem is that when I clicked one and then clicked another many times I have to click a few times on it to produce the action I want (select / deselect according to its current state). That is clear to me that it is because I do not have the correct code that I should.
How would it be solved?
$(document).ready(function() {
// Seleccionar/Deseleccionar de manera individual
Marca_Individual_Seleccionada = false;
//Recibe el evento de que se ha clicado Logo_Marca
$(".Logo_Marca").click(function() {
if (Marca_Individual_Seleccionada == true) {
$(this).removeClass("Marca_Seleccionada");
Marca_Individual_Seleccionada = false;
} else {
$(this).addClass("Marca_Seleccionada");
Marca_Individual_Seleccionada = true;
}
});
// Seleccionar/Deseleccionar TODO a la vez
Seleccionar_Todo = false;
$("#Boton_Marca_Seleccionar_Todo").click(function() {
if (Seleccionar_Todo == false) {
$(".Logo_Marca").addClass("Marca_Seleccionada")
Seleccionar_Todo = true;
} else {
$(".Logo_Marca").removeClass("Marca_Seleccionada")
Seleccionar_Todo = false;
}
});
});