Question: On line 54 we have put a comment, //your code here: Write code that will check if there is no visible section using the code

 On line 54 we have put a comment, //your code here:

On line 54 we have put a comment, //your code here: Write code that will check if there is no visible section using the code above. If there is none, it will use the jQuery show() function on the div with ID #error that we added on line 18 for you.

Try it in the preview in the bottom left hand pane with a wrong section to see if it works.

Good luck!

Hash params
Home page
News page
About page
Error : This section doesn't exist!

Collapse A "problem with JS pages * 4. 4. Fix it The page from the previous section works just fine but there is still a little problem, what happens if we use a wrong section argument, for example example.html#section=thisisnotasection or example.html#thisiswrong? We didn't quite think about that? It displays a white page ... You can try it in the bottom left hand pane A simple way to fix it, would be to check at the end of the current code to see if we do have a section visible, if we don't have any visible section, then we could display an error message. With jQuery we can use the visible after any selector and it will only return the ones that are visible. So if we use $('.section: visible') . It will return all the div 's which have class section and are visible. The rest is simple, if there is no section visible, we display an error message. In jQuery we do that by testing the length of the jQuery object, so $('.section: visible').length will return the number of visible div 's with class

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!