+ 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?
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
+ 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>
+ 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)?
0
have you used onClick ?
0
how does onClick work? Sorry I'm just starting with JS.