tags:

views:

389

answers:

3

Hi guys, I have a problem with jQuery, my code looks ok, but I'm getting an error, which sounds like this:

missing ; before statement [Break on this error] }elseif($('.v_gallery li:first').hasClass('s')){\n

And my code looks like this:

_gallery_pag : function() {
$('#top_pag a').live('click',function() { var _type = $(this).attr('rel');

  switch(_type)
  {
   case '1':
    if($('.v_gallery li:last').hasClass('s'))
    {
     $('.v_gallery li:first').find('a').click();
    }elseif($('.v_gallery li:first').hasClass('s')){
     alert('You can\'t go back!You are at the first page!');
    }
   break;
  }
  return false;
 });  
}

I know, probably I miss spell checked something...because I don't see any problems.

10x guys

+1  A: 

you misspelled else if. Add a space between else and if.

Marius
+1  A: 

"elseif" isn't a keyword in JavaScript, it should be "else if"

Tres
+2  A: 

you wrote elseif instead of "else if" - in javascript, those are two different keywords.

here is your fixed code:

_gallery_pag : function() {
$('#top_pag a').live('click',function() { var _type = $(this).attr('rel');

                switch(_type)
                {
                        case '1':
                                if($('.v_gallery li:last').hasClass('s'))
                                {
                                        $('.v_gallery li:first').find('a').click();
                                }else if($('.v_gallery li:first').hasClass('s')){
                                        alert('You can\'t go back!You are at the first page!');
                                }
                        break;
                }
                return false;
        });             
}
yuval