0
 <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>

I was trying to copy a video on youtube and while doing that the function incdec() is not getting called ..i tried everything but nothing seems to work

3
  • 3
    function = incdec(plusminus)? =? Is that a typo? Commented Jun 27, 2015 at 15:21
  • typo ? sorry i ddnt understand Commented Jun 27, 2015 at 15:22
  • 1
    function = incdec(plusminus) is a syntax error. Hence the question whether = is in your actual code or if it's just a typo in the question. Learn how to debug JavaScript. I also recommend to change the call to incdec(-1) and remove the plusminus = parseInt(plusminus); part. If you want a number then just pass a number. Commented Jun 27, 2015 at 15:25

1 Answer 1

2

There is one syntax error, it's function = incdec(plusminus). Change that to function incdec(plusminus).


    <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

Sign up to request clarification or add additional context in comments.

2 Comments

can u post the code please ?(just that part)..edit:-ah got it thank you :)))
@AmmaarSolkar...pls check my answer(updated), i get alert running and now everything works fine :) vote up if u r happy

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.