From e9ed718a46a97ae40eed4280352d130f5e2c0ce9 Mon Sep 17 00:00:00 2001 From: Frederick Jansen Date: Wed, 2 Sep 2015 20:40:53 -0400 Subject: [PATCH] Fixed issue with number not going up when pressing button --- main.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/main.js b/main.js index c59af61..26ef2a1 100644 --- a/main.js +++ b/main.js @@ -1,10 +1,16 @@ $(function(){ - var oneUp = function(){ - num++; + $('#my-button').on('click', buttonUpHandler); + + function buttonUpHandler(e) { + e.preventDefault(); + var num = parseInt($('#output').text()); + printNum(oneUp(num)); + } + var oneUp = function(num){ + return ++num; }; - var printNum = function(){ - var num = 0; + var printNum = function(num){ $('#output').html(num); }; - printNum(); + printNum(0); }); \ No newline at end of file