mercredi 5 août 2015

Jquery number increment to tag


I am trying to write a variable that holds the main value of the paragraph tag as seen here:

<button id="button">random words</button>
   <p id="inc">0</p>
   <script>
       $(document).ready(function(){
        $('#button').on("click", function(){
          var oldVal = $("#inc")
          $('#inc').text( oldVal + 1)
        });
       });
   </script>

How do I turn the '#inc' into a number so i can do a + 1 increment?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire