jQuery being annoying...

Roon

Member
Mar 31, 2013
60
9
So I'm trying to code a login/logout popover like so...
Code:
    $(document).ready(function(){
        $('.content-login-popover').hide();
    });
    $(document).ready(function(){
        $('#login').click(function (){
            $('.content-login-popover').show();
        }));                                                                     <--------- LINE 7.
    };
$(document).ready(function(){
    $('.content-login-popover').hide();
});
$(document).ready(function(){
    $('#login').click(function(){
        $('.content-login-popover').show();
    }));
});

However, when I do this, I'm getting an error saying...
c29e2f1921d50176abe9ee418fcce22f.png

"15:11:17:845 - SyntaxError: missing ; before statement - main-scripts.js:7"

Thanks in advance :)
 

Sysode

Front-End Developer
Dec 11, 2012
1,673
848
Like said, why do you have three brackets?

Anyway, try this;

Code:
 $(document).ready(function(){
        $('#login').click(function (){
            $('.content-login-popover').show();
        }));                                                                    <--------- LINE 7.
    };

Change to:

Code:
 $(document).ready(function(){
        $('#login').click(function (){
            $('.content-login-popover').show();
        });                                                                    <--------- LINE 7.
    });
 

Markshall

Русский Стандарт
Contributor
Dec 18, 2010
2,638
2,393
Not quite sure why you did $(document).ready, did one line of code and then ended it and restarted it 4 times. This will suffice.

You also had two unneeded brackets.

Code:
$(document).ready(function(){
    $('.content-login-popover').hide();
 
    $('#login').click(function(){
        $('.content-login-popover').show();
    });
 
    $('.content-login-popover').hide();
 
    $('#login').click(function(){
        $('.content-login-popover').show();
    });
});
 

Roon

Member
Mar 31, 2013
60
9
I didn't realize that there was another way to do jQuery, I thought you had to keep saying "if document is ready do this..." for each thing.
What is the more 'professional' way?
 

Markshall

Русский Стандарт
Contributor
Dec 18, 2010
2,638
2,393
I didn't realize that there was another way to do jQuery, I thought you had to keep saying "if document is ready do this..." for each thing.
What is the more 'professional' way?

Not to blow my own trumpet, but the more 'professional' way is the way I did it, where you call jQuery once on document.ready and then start using it properly to do tricks and shit, yo.
 

Users who are viewing this thread

Top