I am trying to add/subtract from a number inside a span tag. This is depenent on a checkbox. Here is the jquery I'm trying:
//If checked
var $newprice = $("#totalprice").val() + 299;
$("#totalprice").text($newprice);
//If NOT checked
var $newprice = $("#totalprice").val() - 299;
$("#totalprice").text($newprice);
If I check the box, it adds 299, but unchecked changes the number to -299.
Aucun commentaire:
Enregistrer un commentaire