$index.val() returns the value. $index.val(VALUE); assigns VALUE.

So, this should (might) work:

$index.val(--$index.val())

It doesn't look so great, though. I say "might" because I'm not sure
if that needs to be set as a var, first.

You also want the decrement on the left or you'll be decrementing the
value after you assign it, where the decrement will not have any
effect (because the pre-decremented value was assigned).



On Tue, Feb 10, 2009 at 9:07 PM, shapper <mdmo...@gmail.com> wrote:
>
> Hello,
>
> I have an input on my page as follows:
>
>  <input id="Index" name="Index" type="hidden" value="0" />
>
> I am trying to increase and decrease the value of the input as
> follows:
>
>        $index = $('#Index');
>        $index.val()--;
>
> I always get an error:
> invalid assignment left-hand side
>
> What am I doing wrong?
>
> Thanks,
> Miguel
>
>

Reply via email to