1

I'm trying to get the following to output to 2 decimal places:

$("#incP1").click(function(){
  $(":text[name='qty1']").val( Number($(":text[name='qty1']").val()) + 1 );
  $(":text[name='cost1']").val( Number($(":text[name='cost1']").val()) + 1.99 ) ;
});

I've been trying to use toFixed(2), but with no luck. Any advice would be great.

gen_Eric
  • 223,194
  • 41
  • 299
  • 337
Lee Banks
  • 13
  • 3

1 Answers1

0

This should work:

$(":text[name='qty1']").val( (+$(":text[name='qty1']").val() + 1).toFixed(2) );
A. Wolff
  • 74,033
  • 9
  • 94
  • 155