yahya
yahya

Reputation: 3

Uncaught SyntaxError: Unexpected token '}'

Where is the error in writing this post?

<script>
$(function(){
    $("#teacher").clik(function({
        $("#login_teachers").slideToggle();
        $("#login_teachers").css('display', 'block');
        $("#login_parents, #login_students").css('display', 'none'),
    });

    $("#parents").clik(function({
        $("#login_parents").slideToggle();
        $("#login_parents").css('display', 'block');
        $("#login_teachers, #login_students").css('display', 'none'),
    });        

    $("#students").clik(function(){ 
        $("#login_students").slideToggle();
        $("#login_students").css('display', 'block');
        $("#login_parents, #login_teachers").css('display', 'none');
    });   
});
</script>

I'm getting the error

Uncaught SyntaxError: Unexpected token '}'

Upvotes: 0

Views: 1386

Answers (1)

Roberto Caboni
Roberto Caboni

Reputation: 7490

There are two different errors (each repeated three times):

  1. There's a typo in the click event handlers definition: your code wrongly contains clik, instead.
  2. Every last line of the event handlers, for example $("#login_teachers, #login_students").css('display', 'none'), is terminated by a comma instead of a semicolon.

The "Unexpected token '}'" error is due to the second mistake.

Upvotes: 1

Related Questions