html - Hide a page section then reveal it when a link is clicked- JQuery -


i have question within page , want user able able have go answering before answer revealed. have 2 options. 1 link show clues , ideas , 1 link show completed conclusion. firstly tried setting original property not display section using .show() reveal wasn't working. had working code similar purpose tried using .addclass method instead. didn't work either assume must links or can't see because new jquery. advice appreciated! here's code:

    <section id="page6section2"><div class="page-header"><h1>some ideas</h1></div>     <section id="page6section3"><div class="page-header"><h1>conclusion</h1></div>      <p><a href="#page6section2" id="someideas">click here clues , ideas!</a>     </p>     <p><a href="#page6section3" id="conclusion">click here conclusion!</a> 

    .hidesection2 {display: none;}     .hidesection3 {display: none;}          $(function() {     $('#page6section2').addclass('hidesection2');});     jquery('#someideas').click(function(){     jquery('#page6section2').removeclass('hidesection2'); });     $(function() {     $('#page6section3').addclass('hidesection3');});     jquery('#conclusion').click(function(){     jquery('#page6section3').removeclass('hidesection3'); }); 

i'm sure there easier , more condensed way too.

put function window load:

jquery(window).load(function(){    $('#page6section2').addclass('hidesection2');    jquery('#someideas').click(function(){        jquery('#page6section2').removeclass('hidesection2');     });     $('#page6section3').addclass('hidesection3');    jquery('#conclusion').click(function(){         jquery('#page6section3').removeclass('hidesection3');     }); }); 

your links dom might not yet been loaded when script executed. thats why should put windows.load


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -