It works, see my jsFiddle
var index = 0;
var count = 0;
switch (index) {
case 0:
count = count - 5;
$('#point p').text(count);
break;
case 1:
count = count + 2;
$('#point p').text(count);
break;
case 2:
count = count + 5;
$('#point p').text(count);
break;
}
Note. The string $('#point p').text(count);will always be the same in all cases, so you might want to put it after the switch case.
Also, I replaced your string: document.getElementById("point").getElementsByTagName('p')[0].innerText = count;with $('#point p').text(count)to use jQuery. Hope this helps you get started.
source
share