-1

I'm trying to set up a counter using a variable. Right now I have one big div with two smaller divs under it. I want to set up my jquery/javascript so that clicking on the lower div on the right hand side will make numbers in the bigger div at the top of the page go up. In other words, when the page loads the big div will have "1" displayed on it. Clicking the div below it on the right should making it go up to "2" - clicking again should make it go to "3" etc. Clicking on the left hand div should make it go downwards i.e. from "6" down to "5" and so on. Any advice on how to do this? Sorry if my question isn't worded properly; I'm new to this stuff and still struggling with it. Any help would be appreciated. Thanks!

  • This posts will help you check it out, http://stackoverflow.com/questions/4701349/jquery-increase-the-value-of-a-counter-when-a-button-is-clicked http://stackoverflow.com/questions/12319598/jquery-mouse-click-counter – Chinmaya Hegde Nov 13 '13 at 05:34

1 Answers1

0

without seeing your markup its hard to suggest code but here is a first attempt: Markup:

<div id="bigDiv">1</div>
<div id="clickDiv"><button id="btnIncrement">Increase</button></div>

jQuery:

$("#btnIncrement").click(function() {
    var num = parseInt($("#bigDiv").text());
    $("#bigDiv").text(num++);

})
hammus
  • 2,602
  • 2
  • 19
  • 37