当前位置: 移动技术网 > IT编程>网页制作>CSS > 鼠标与按键事件触发顺序

鼠标与按键事件触发顺序

2019年06月02日  | 移动技术网IT编程  | 我要评论

鼠标与按键事件触发顺序。事件触发顺序:
之前研究过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');
    }

事件触发顺序:
mousedown
focus
mouseup
click

keydown
input(文本框内容改变,输入或者删除都会触发)
keyup
change(文本框失去鼠标焦点,并且内容改变时触发)

注:搜狗输入法,当输入汉字,拼音在文本框显示下划线状态,也会触发keydown,input,keyup事件。

</script>

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网