3 回答

TA貢獻(xiàn)1876條經(jīng)驗(yàn) 獲得超5個(gè)贊
let form = document.getElementById("form");
let input = form.children["input"];
let send = form.children["send"];
form.addEventListener("submit", (e) =>
{
// Use Ajax to send the message to php page.
if (input.value.length !== 0)
{
console.log(input.value);
}
// Reset the input:
input.value = "";
// Disable the submit:
e.preventDefault();
});
send.addEventListener("focus", (e) =>
{
input.focus();
});
<form class="panel" id="form">
<input name="input" type="text" class="message" autocomplete="off" spellcheck="false"/>
<button name="send" class="send">S</button>
</form>
添加回答
舉報(bào)