この記事の例は、テキストボックスのDivレイヤーのJS入力テキストボックスのテキストボックスコンテンツのコンテンツを同期する方法を示しています。参照のためにそれを共有してください。特定の実装方法は次のとおりです。
次のようにコードをコピーします。<
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<Meta http-equiv = "content-type" content = "text /html; charset = gb2312" />
<title>テキストをテキストボックスに入力し、ページのDivレイヤーのテキストボックスのコンテンツを同期します</title>
<style>
Textarea {width:300px; height:150px;ボーダー:1pxソリッド#ccc;フォントサイズ:12px;色:#000;}
p {パディング左:30px;テキストインデント:-30px;幅:270px;高さ:250px;国境:1pxソリッド#900;マージントップ:50px;フォントサイズ:12px;色:#f00;ラインハイト:21px;オーバーフロー:隠し}
</style>
<script type = "text/javascript">
functionswaptxt()
{
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">コードホームヒント:www.vevb.comなどのテキストボックスにテキストを入力してください</p>
</body>
</html>
この記事がみんなのJavaScriptプログラミングに役立つことを願っています。