Changing value of button using typescript -
i'm trying make button (which says "add favorites) change "remove favorites" once it's clicked. i've tried lot of solutions on site (for both java , textscript), nothing seems working.
my code:
button(id='addtofav', onclick='addtofavorites()') add favorites script. function addtofavorites(){ var x = document.getelementbyid("addtofav").value; if (x=="add favorites") { x = "remove favorites"; } else { x = "add favorites"; } }
thank help!
assigning new text "x" not update button text. assign this.
function addtofavorites(){ var x = document.getelementbyid("addtofav").value; if (x=="add favorite") { document.getelementbyid("addtofav").value = "remove favorite"; } else { document.getelementbyid("addtofav").value = "add favorite"; } }
Comments
Post a Comment