Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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: 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!
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started