cordova/phonegap onclick doesn't work

前端 未结 7 2051
小鲜肉
小鲜肉 2021-01-21 14:34

I try to create button which starts an alert after a click event. Something like that :

    
    

Apache

7条回答
  •  醉酒成梦
    2021-01-21 15:31

    Solution

    // Function to change the content of t2

    function modifyText() {
      var t2 = document.getElementById("t2");
      if (t2.firstChild.nodeValue == "three") {
        t2.firstChild.nodeValue = "two";
      } else {
        t2.firstChild.nodeValue = "three";
      }
    }
    

    // add event listener to table

    var el = document.getElementById("outside");
    el.addEventListener("click", modifyText, false);
    

提交回复
热议问题