+ 1

Back button in JS function

I created a button in an Html page connected to a function, I click the button and I process the function. Then how can I put a back button in the function so that once i processed it I'll have a new button to get back to the first Html page?

19th Oct 2018, 8:43 PM
Alessandro Palazzolo
Alessandro Palazzolo - avatar
5 Answers
+ 5
create 2 buttons at first, but set button2.style.display="none" and add button2.style.display="block" into button1's event, so that button2 will appear when button1 is clicked
20th Oct 2018, 4:59 AM
Flandre Scarlet
Flandre Scarlet - avatar
+ 2
<button id="first" onclick="click_first()" type="button">First</button> <button id="second" onclick="click_second()" type="button" hidden>Second</button> <script> function click_first(){ // ... here goes your handlers document.querySelector('#second').removeAttribute('hidden'); } function click_second() { alert('Hello Alessandro') } </script>
19th Oct 2018, 10:22 PM
Sergei No
Sergei No - avatar
+ 1
Sounds like a silly question, I promise it isn't: When you click the button, does your page navigate (but ideally, it should not navigate at all)?
19th Oct 2018, 11:22 PM
Kirk Schafer
Kirk Schafer - avatar
0
have you used onClick ?
19th Oct 2018, 9:14 PM
Abhishek Tripathy
Abhishek Tripathy - avatar
0
how does onClick work? Sorry I'm just starting with JS.
19th Oct 2018, 10:06 PM
Alessandro Palazzolo
Alessandro Palazzolo - avatar