Reputation: 285
I've been doing some searching about updating a div containing a scoreboard but I can't really get to the bottom of it. Is there any downside of using innerHTML, what other options are there?
What I'm trying to get is a score that updates every time the score changes, which at the moment is where the correct/incorrect alerts are as well.
Excerpt from the fiddle:
if(pick1 == pick2 && id1!=id2){
alert('Correct');
score += 100;
}
http://jsfiddle.net/94jerdaw/Sr3Yp/
Upvotes: 1
Views: 1366
Reputation: 5148
There is nothing wrong with innerHTML or innerText, but you might want to look into frameworks like jQuery to do that.
Upvotes: 1
Reputation: 1363
Consider using jQuery to update the scoreboard's html:
$('.scoreboard').html(score);
pick1 = false;
Upvotes: 1