Bingo. Thanks all for you straightforward answers. This had been
dogging me for days.

Thanks!

On Aug 3, 5:12 pm, Peter Edwards <p...@bjorsq.net> wrote:
> Hi Nick
>
> $(".number").html(count--);
>
> count-- decrements your count variable after it has passed its value to
> the $.html() function.
> use --count
>
> Peter
>
> on 03/08/2009 21:15 littlerobothead said::
>
>
>
> > I have a status area in an app I'm working on. It shows the number of
> > unread alerts. As the user clicks each alert, it's subtracted from the
> > total. The following code counts the number of items to use as my
> > total:
>
> > var trigger = $("#dataset-b tr.unread");
> >    var count = $(trigger).length;
> >    $(".number").html(count);
>
> > And then this works to subtract from that number on each click:
>
> >    $(trigger).click(function(){
> >            $(".number").html(count--);
> >            if (count == 0){
> >                    $(trigger).unbind("click");
> >            }
> >            $(this).removeClass('unread');
> >    });
>
> > Problem is, nothing happens on the first click. However, on the second
> > click my number starts to decrement. What's going on here? How can I
> > make the count work?
>
> > Best,
> > Nick

Reply via email to