When an event happens i want to reduce the value of an input named "shareNum" by 1. This is what i currently use:
$( "#shareNum" ).val(($(this).val-1) );
I get a "NaN" - a non value.. something is wrong, any thoughts?
Try like this:
var $shareNum = $("#shareNum");
$shareNum.val(Number($shareNum.val()) - 1);
And here's a live demo.
text()rather thanval(). And, obviously, with sanity checks to ensure it's a valid number.