This article example illustrates how to synchronize the content of the text box content in the JS input text box in the div layer in the text box. Share it for your reference. The specific implementation method is as follows:
Copy the code 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 into the text box, and synchronize the content of the text box in the div layer on the page</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="" id="eml" onkeyup="SwapTxt()"></textarea>
<p id="lyny">Code Home Tips: Please enter text in the text box above, such as www.VeVB.COM</p>
</body>
</html>
I hope this article will be helpful to everyone's JavaScript programming.