鼠标与按键事件触发顺序。事件触发顺序:
之前研究过input文本框的事件触发顺序,今天突然想起来,就做个总结。
<script> var txt = document.queryselector('#txt'); txt.onmousedown = function(){ console.log('onmousedown'); } txt.onmouseup = function(){ console.log('onmouseup'); } txt.onfocus = function(){ console.log('onfocus'); } txt.onclick = function(){ console.log('onclick'); } txt.onkeydown = function(){ console.log('onkeydown'); } txt.onkeyup = function(){ console.log('onkeyup'); } txt.onchange = function(){ //文本框失去鼠标焦点,并且内容改变时触发 console.log('onchange'); } txt.oninput = function(){ console.log('oninput'); }
</script>事件触发顺序:
mousedown
focus
mouseup
clickkeydown
input(文本框内容改变,输入或者删除都会触发)
keyup
change(文本框失去鼠标焦点,并且内容改变时触发)注:搜狗输入法,当输入汉字,拼音在文本框显示下划线状态,也会触发keydown,input,keyup事件。
如对本文有疑问, 点击进行留言回复!!
荐 微信小程序动态评分展示/五角星展示/半颗星展示/自定义长度展示
深入理解CSS background-blend-mode的作用机制
网友评论