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

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -