ユーザーが a の値を変更したときにリンクを編集したいのですが、<input type="text">
うまくいきません。私のHTML:
<head>
<link rel="stylesheet" href="styles.css" />
<script type="text/javascript">
function updateGiveLink() {
document.getElementById("givelink").innerHTML = "http://kroltan.eliti.com.br/diamonds/?give="+document.getElementsById("givetext").value;
document.getElementById("givelink").href = "http://kroltan.eliti.com.br/diamonds/?give="+document.getElementsById("givetext").value;
}
</script>
</head>
<input type="text" placeholder="Minecraft username" name="give" id="givetext" onchange="updateGiveLink()" />
<a id="givelink" href="http://kroltan.eliti.com.br/diamonds/?give=Player">http://kroltan.eliti.com.br/diamonds/?give=Player</a>
これは の URL と表示テキストを変更して、URLgivelink
の?give=
一部にテキスト フィールドの値を持たせることになっていますgivetext
。しかし、期待どおりに機能していません。代わりに、何もしません。私も and を使用しonkeyup
てoninput
みました (これらは別の関連する質問で見ました)、成功しませんでした。