I have a counter on my html page and im trying to use a button to increment the counter by 1 when using the + button, and decrease the counter by 1 when using the - button, with a maximum of 10 counts (0 minimum). Problem is the javascript doesnt seem to work at all. When I click the buttons, nothing happens. I have google hosting jquery in my header. I've tried this on js fiddle and it works but not on my page. Any help would be greatly appreciated.
html (these are inside a div)
<button onclick="countDown();">-</button>
<span id="counter">0</span>
<button onclick="countUp();">+</button>
Javacript
<script type="text/javascript">
var minVal = 0, maxVal = 10, clicks = 0,
display = document.getElementById("counter");
function countUp() {
clicks = Math.min(maxVal, clicks + 1);
display.innerHTML = clicks;
}
function countDown() {
clicks = Math.max(minVal, clicks - 1);
display.innerHTML = clicks;
}
</script>
Edit: the script is in my header after the jquery script