copy content from a <p> element to hidden <input> element? - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Paragraph

Description

copy content from a <p> element to hidden <input> element?

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
function myFunction() {/* w w  w . j a v  a 2s.  co m*/
   document.getElementById("output").value = document.getElementById("input").innerHTML;
}

      </script> 
   </head> 
   <body> 
      <p id="input" contenteditable="true" onkeyup="myFunction()">This is a paragraph. </p> 
      <input type="text" id="output">  
   </body>
</html>

Related Tutorials