Jump to content

ValJor

Members
  • Posts

    2
  • Joined

  • Last visited

ValJor's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. That is fantastic @Ingolme! Such a simple and elegant solution. I'll apply this to my program. Thank you very much!
  2. Hi! Note: first time posting here. In my code (example below) the input on div2 works as expected, but the one in div1 does not, it doesn't maintain focus after I click on it. The function does change the content of the div, but it does not allow me to enter a value. What do I have to do to make the input in div1 behave the same way as the input in div2? Is there another event that works like onclick but keeps the focus after we "unclick"? <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Changing the content of a div by clicking on it</title> <script> function div1_was_clicked() { document.getElementById("div1").innerHTML = '<input type="text">'; } </script> </head> <body> <div id = "div1" onclick="div1_was_clicked();"> <p>1 2 3</p> </div> <div id = "div2"> <input type="text"> </div> </body> </html>
×
×
  • Create New...