Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inline `++` in Javascript not working

Astonished to find out that a line like this :

$('#TextBox').val(parseInt($('#TextBox').val())++ );

Will not work !

I've done some tests, it plays out to the conclusion that the inline ++ doesn't work (in Javascript as a whole ? Or simply in my example ?).

Here's a test with three pieces of code, it seems that ++ is ok with a variable but not inline.

So, no inline ++ for us in Javascript?

like image 703
Akheloes Avatar asked Dec 16 '22 08:12

Akheloes


1 Answers

There's nothing particular to jQuery about this. ++ increments a variable. You are trying to increment the return value of a function call.

like image 67
Quentin Avatar answered Dec 17 '22 22:12

Quentin