12
วิธีรับข้อความของกล่องข้อความอินพุตระหว่าง onKeyPress?
ฉันกำลังพยายามรับข้อความในกล่องข้อความตามที่ผู้ใช้พิมพ์ ( jsfiddle playground ): function edValueKeyPress() { var edValue = document.getElementById("edValue"); var s = edValue.value; var lblValue = document.getElementById("lblValue"); lblValue.innerText = "The text box contains: " + s; //var s = $("#edValue").val(); //$("#lblValue").text(s); } <input id="edValue" type="text" onKeyPress="edValueKeyPress()"><br> <span id="lblValue">The text box contains: </span> เรียกใช้ข้อมูลโค้ดHide resultsขยายข้อมูลโค้ด รหัสทำงานโดยไม่มีข้อผิดพลาดยกเว้นว่าค่าของinput textกล่องระหว่างonKeyPressจะเป็นค่าก่อนการเปลี่ยนแปลงเสมอ: คำถาม …