Javascript函数未调用onclick

时间:2015-06-27 15:20:07

标签: javascript jquery html function onclick

 <body ng-app="starter">

<ion-pane>
  <ion-header-bar class="bar-dark">
    <h1 class="title">LifeApp</h1>
  </ion-header-bar>
  <ion-content>

    <center><div class="card" id="life"><h3>20</h3></div></center>
    <div class="button-bar">
        <a class="button" onclick="incdec('-1')">-1</a><!-----------this function call----->
        <a class="button">+1</a>
    </div>
    <br />
    <div class="button-bar">
        <a class="button">-5</a>
        <a class="button">+5</a>
    </div>
    <br />

    <div class="button-bar">
        <a class="button">Roll Dice</a>
        <a class="button">0</a>
    </div>
    <br />
    <center><a class="button">Reset</a></center>
  </ion-content>
</ion-pane>
<script>
    function = incdec(plusminus){
        alert('running');
        plusminus = parseInt(plusminus);
        currentlife = document.getElementById("life").innerHTML + plusminus;
        document.getElementById("life").innerHTML = currentlife;
    }
</script>

我试图在youtube上复制一个视频,虽然这样做的功能incdec()没有被调用..我尝试了一切,但似乎没有任何工作

1 个答案:

答案 0 :(得分:2)

有一个语法错误,它是function incdec(plusminus)。将其更改为An unknown error has occurred. Message:org.springframework.dao.EmptyResultDataAccessException: No entity found for query No entity found for query.


    <script>
        function incdec(plusminus){
            alert('running');
            plusminus = parseInt(plusminus);
            currentlife = document.getElementById("life").innerHTML + plusminus;
            document.getElementById("life").innerHTML = currentlife;
        }
    </script>

enter image description here