表单事件
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>表单事件</title> </head> <body> <form action=""> <input type="text" name="usr"> <button type="submit">提交</button> <div></div> </form> </body> <script type="text/javascript"> var form = document.querySelector(‘form‘) var ipt = document.querySelector(‘input‘) var btn = document.querySelector(‘button‘) ipt.onselect = function () { console.log(‘文本被选中‘); }; var div = document.querySelector(‘div‘) // ipt.oninput = function () { // console.log(‘值改变‘); // div.innerText = this.value // }; // ipt.onkeyup = function () { // div.innerText = this.value // } // ipt.onchange = function () { // div.innerText = this.value // } form.onsubmit = function () { console.log(‘提交‘) return false; } </script> </html>
相关推荐
前端开发Kingcean 2020-07-08
liaoxuewu 2020-05-11
SIMONDOMAIN 2019-12-13
哈喽elements 2019-11-19
liaoxuewu 2019-11-03
切慕溪水 2019-11-03
xiaoge00 2019-10-26
duxd 2019-05-10
bistukey 2019-07-01
JackXue程序生涯 2019-07-01
JackXue程序生涯 2019-07-01
adeyi 2019-07-01
sunnylin 2019-06-30
LingPF 2019-06-28
jianqi 2019-06-28
莲开十月人思量 2019-06-28
云海梦尘 2014-02-24
Danielmumu 2013-11-04
racy 2019-06-25