javascript - How to prevent a button from going to original state when refreshed -
i have button #first
upon click replaced #second
. after getting second button , if refresh page going first button. if want button second button after refresh how can achieve this? thank in advance
<!doctype html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> <script> $(document).ready(function() { $("button").click(function() { $("#first").replacewith('<button id="second">second button</button>'); }); }); </script> </head> <body> <button id="first">firstbutton</button> </body> </html>
set cookie persist state of button , on document.ready,fetch saved state , display such.
Comments
Post a Comment