I am creating a mobile web app, I have a login/ signup page where users can choose the method they want. In order to reduce the refresh rate of pages I am hiding and showing objects depending on what the user clicks with jquery.
I have virtual back buttons on each of the 'pages' which hide/show the objects including the back buttons themselves, each time I need to add an extra 'page' I have to add and call the different buttons.
Is there a way I can have one button and use that depending on what elements are hidden/shown?
e.g
html
<div id="go_button"</div> <div id="next_button"</div <div id="backbutton1"</div> <div id="backbutton2"</div> <div id="page1" <p> some information here </p> </div> <div id="page2" <p> some more information here </p> </div> jQuery
$("#gobutton").click(function(){ $('#backbutton1').fadeIn(250); $('#page1').fadeIn(250); $('#next_button').fadeIn(250); }); $('#next_button').click(function(){ $('#backbutton1').hide(); $('#backbutton2').show(); $('#page1').fadeOut(250); $('#page2').fadeIn(250); $('#next_button').fadeOut(250); $("#backbutton1").click(function(){ $('#backbutton1').fadeOut(250); $('#page1').fadeOut(250); $('#next_button').fadeOut(250); }); etc etc