var boton = document.getElementById("ejemplo"); boton.addEventListener("click", function(){ var estado = this.getAttribute("data-estado"); if (estado == "no"){ this.innerText = "Ya no me gusta"; this.setAttribute("data-estado", "si"); estado = "si"; } else{ this.innerText = "Me Gusta"; this.setAttribute("data-estado", "no"); estado = "no"; } }, false);
<button id = "ejemplo" data-estado = "no">Me gusta</button>