js implements the text box input text page in the div layer synchronized access to the text box content method

  • 2020-05-10 17:39:28
  • OfStack

The example of this article describes the method of js implementing the div layer to synchronously obtain the content of the text box in the text box input text page. Share with you for your reference. The specific implementation method is as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title> Enter text in the text box on the page div The layer synchronizes the text box content </title>
<style>
textarea{width:300px;height:150px; border:1px solid #CCC; font-size:12px; color:#000;}
p{ padding-left:30px; text-indent:-30px;width:270px;height:250px; border:1px solid #900; margin-top:50px; font-size:12px; color:#F00; line-height:21px; overflow:hidden}
</style>
<script type="text/javascript">
 function SwapTxt()
  {
      var txt = document.getElementById("eml").value;
      document.getElementById("lyny").innerHTML=txt;
  }
</script>
</head>
<body>
  <textarea name="" cols="" rows="" class="loe_hk10" id="eml" onkeyup="SwapTxt()"></textarea>
  <p id="lyny"> Code home prompt: please enter text in the text box above, such as www.ofstack.com</p>
</body>
</html>

I hope this article is helpful for you to design javascript program.


Related articles: