Changing button text onclick

后端 未结 18 2517
野性不改
野性不改 2020-11-27 03:10

When I click on myButton1 button, I want the value to change to Close Curtain from Open Curtain.
HTML:

<         


        
18条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-27 03:52

    this code work for me

      var btn = document.getElementById("your_btn_id");
        if(btn.innerText=="show"){
           btn.innerText="hide";
          }
        else{
          btn.innerText="show";
          }
    

    using value is not work in my case

提交回复
热议问题