Amazingly simple as it sounds, i’m having difficulty managing this.
Simply put, if i click an element with id “Counter” while the shift key is pressed, the int wrapped by Total should go up. If alt is held when clicked, it goes down.
$('#Counter').click(function(x) {
if(x.altKey) {
$('#Counter').html(parseInt($('#Total').html())-1);
}
if (x.shiftKey) {
$('#Counter').html(parseInt($('#Total').html())+1);
}
});
///////////
<div id="Counter"><span id="Total">100</span></div>
I can see your problem, you want to parse
<span id="Total">100</span>into a number. You can’t do this. Also you set the html of#counterto a number and so you loose#Total.What you want, is: