Ryan
Ryan

Reputation: 1791

If statement for jquery

How to make this right?

$(this).click(function(){
   if(showLarge == 1 && !$('.loginLarge_wrap')){
     //
   }
});

The idea here is that, there's a condition showLarge equals to 1 and not equals to .loginLarge_wrap

Thank you.

Upvotes: 0

Views: 85

Answers (2)

Abhishek Mehta
Abhishek Mehta

Reputation: 1445

You can use jQuery method - hasClass() to check to see if the class - '.loginLarge_wrap' is present instead of doing

showLarge != $('.loginLarge_wrap' )

Assuming showLarge is a DOM element. you can do something like this:

if($(showLarge).val() == 1 && (!$(showLarge).hasClass('.loginLarge_wrap')))

Upvotes: 0

Cofey
Cofey

Reputation: 11414

$(this).click(function() {
    if ( ( showLarge == 1 ) && ( showLarge != $('.loginLarge_wrap' ) ) ) {
        //
    }
});

Upvotes: 3

Related Questions