+ 1

SyntaxError: unexpected token ) line:36

When you click on the circle it disappear and when you click on show, it show the circle https://code.sololearn.com/WG6GLyTaWHyx/?ref=app

17th Mar 2018, 12:03 AM
Hamza Ait
Hamza Ait - avatar
3 Antworten
+ 2
The message error is explicit for one of your mistakes: parser find an unexpected closing parenthesis (round closing bracket) at line 36... Writing logical indentation and understanding what you code help to avoid and/or correct this kind of syntax error ^^ $("#top-bar") select the element with id "top-bar" (argument is expected to be a css selector syntax) by returning the reference of the targeted element. Appending something after a dot is just a shorthand writing to use this returned reference. If the reference is stored in a variable, this is a JQuery html reference object, which provide the 'click()' method, to assign a function (expected as argument of the method) to be executed when user click on the targeted element. 'top-bar' is your circle element, so you pass a function which select again the 'top-bar' element, on which it call the method 'hide()', and nothing else (actually, there is the first mistake: you doesn't close both the function declaration (with a curly closing bracket) and the parenthesis expected to enclose the argument of the 'click()' method call... Once this is corrected, there's still the syntax error of unexpected token, because in a same way, you have one spare closing parenthesis... removing it fix the syntax error itself, but there's still a logical error, as inside the second initialization of onclick event (for the 'show' button element), you pass a function wich is intented to show the 'top-bar' circle element, but you target the button instead. So fixed javascript should be: $("#top-bar").click(function(){ $("#top-bar").hide(); }); $("#show").click(function (){ $("#top-bar").show(); });
17th Mar 2018, 12:38 AM
visph
visph - avatar
0
You messed up with brackets. Here is working code https://code.sololearn.com/W1FUurxD409z/?ref=app
17th Mar 2018, 12:28 AM
Vladi Petrov
Vladi Petrov - avatar
0
You are missing last }
17th Mar 2018, 12:29 AM
Toni Isotalo
Toni Isotalo - avatar