Search code examples
jqueryfunctionlive

jQuery live function not working


Further to my last question I need to add in the .live() function as i'm adding the content dynamically

This is what I have now

$('.PointsToggle').live('each',function() {
              $this = $(this);
              if ($this.text() == 'POINTS STATEMENT - AVAILABLE 7AM TOMORROW') {
                $this.width(510);
              } else {
                $this.width(20);
              }
            })

But this doesn't seem to work now

Any ideas?

Thanks

Jamie


Solution

  • For this sort of thing you will need the livequery plugin

    $('.PointsToggle').livequery(function() {
      var $this = $(this);
      if ($this.text() == 'POINTS STATEMENT - AVAILABLE 7AM TOMORROW') {
        $this.width(510);
       } else {
        $this.width(20);
       }
    })