0
How to create a page with a btn and when clicked prompts to enter text which shd be shown&when text is clicked it must be delete
Use js with prompts
1 Resposta
0
Well without writing all the code myself here:
1)create a button element (through HTML or JS)
2)create function that prompts the user for input and store the input in a variable.
In the same function (or a separate one) show the variable value (create a html element, add the value of the variable to the innerText property of the element. Then add the element to the DOM)
3) let the promptForInput function be triggered by the buttons onClick event.
4) For the element that shows the text, also add an onClick event and that triggers a function that removes the element from the DOM