Only recognizes the attributes and values of the first ID, does not respect the following. I show my code below:
index.php
<button type="button" id="boton_uno" class="boton-estado">Boton 1</button>
<button type="button" id="boton_dos" class="boton-estado">Boton 2</button>
functionality.js
$('#boton_uno').attr('estado', opcion1);
$('#boton_dos').attr('estado', opcion2);
$('#boton_uno').html(label1);
$('#boton_dos').html(label2);
var boton1 = document.querySelector("#boton_uno");
var boton2 = document.querySelector("#boton_dos");
if (estado == 0) {
boton1.style.backgroundColor = "green";
boton2.style.backgroundColor = "orange";
} else if (estado == 1) {
boton1.style.backgroundColor = "red";
boton2.style.backgroundColor = "orange";
} else if (estado == 2) {
boton1.style.backgroundColor = "red";
boton2.style.backgroundColor = "green";
}
$('.boton-estado').click(function(){
//aqui va codigo...
}
});
.js code: link