0

I have two divs in which there are buttons to do certain action: on first button click I want this button to hide and another to show. If i click on the new button it should hide the button and come back to the first one. It's working perfectly fine however I would like to add action for browser "back" button so it works the same way as I would click the 2nd button when the user is after first action.

<div class="firstdiv"> 
<a class="gototwo"> Go to Step 2 </a>
</div>
<div class="seconddiv" style="display:none"> 
<a class="gotofirst"> Go back to Step 1 </a>
</div>

Working fiddle here: https://fiddle.jshell.net/Lp6yjux7/

I've been reading it's possible to prevent default action but I don't know how to implement it in the jquery code I already have.

  • I don't think it is possible to affect the back button on the browser itself, that sounds like a security risk. You can have a look at hashing, this question might point you in the right direction http://stackoverflow.com/questions/5601864/change-location-hash-and-then-press-back-button-ie-behaves-differently-from-ot – Chris Feb 28 '16 at 09:47
  • Additionally, you could also check out this neat little plugin: https://github.com/browserstate/history.js – Adam Baranyai Feb 28 '16 at 11:27

0 Answers0