In diesem Artikel wird gezeigt, wie der Inhalt des Textfeldinhalts im JS -Eingabegtextfeld in der Div -Ebene im Textfeld synchronisiert wird. Teilen Sie es für Ihre Referenz. Die spezifische Implementierungsmethode lautet wie folgt:
Kopieren Sie den Code wie folgt: <! 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">
<kopf>
<meta http-äquiv = "content-type" content = "text /html; charset = gb2312" />
<title> Geben Sie den Text in das Textfeld ein und synchronisieren Sie den Inhalt des Textfelds in der DIV -Ebene auf der Seite </title>
<Styles>
textarea {width: 300px; Höhe: 150px; Grenze: 1PX Solid #CCC; Schriftgröße: 12px; Farbe:#000;}
p {padding-links: 30px; Text-Indent: -30px; Breite: 270px; Höhe: 250px; Grenze: 1PX Solid #900; Rand: 50px; Schriftgröße: 12px; Farbe:#f00; Zeilenhöhe: 21px; Überlauf: versteckt}
</style>
<script type = "text/javaScript">
Funktion Swaptxt ()
{
var txt = document.getElementById ("eml"). Wert;
document.getElementById ("Lyny"). Innerhtml = txt;
}
</script>
</head>
<body>
<textArea name = "" cols = "" rows = "" id = "eml" onkeyup = "swaptxt ()"> </textArea>
<p id = "lyny"> code home tipps: Bitte geben Sie Text in das Textfeld oben ein, z. B. www.vevb.com </p>
</body>
</html>
Ich hoffe, dieser Artikel wird für JavaScript -Programme aller hilfreich sein.