Changing button text onclick

后端 未结 18 2510
野性不改
野性不改 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 04:00

    Or more simple without having to name the element (with 'button' element):

    
    

    and script :

    var bWriteLog = true;
    
    function toggleLog(elt) {
    
      bWriteLog = !bWriteLog;
      elt.innerHTML = bWriteLog ? 'Stop logs' : 'Watch logs';
    }
    

提交回复
热议问题