Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

clipboard.png

如图 用光标选中上述问题并backpace后光标会跑到输入框末尾,想要的结果应该是删除完后光标不动

具体代码

clipboard.png


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
346 views
Welcome To Ask or Share your Answers For Others

1 Answer

是这句话照成的

this.value = this.value.replace(/[^d]/g, '');

在上面加上一句话变为:

//将backspace按键过滤掉
if (e.keyCode === 8) {
    return;
}
this.value = this.value.replace(/[^d]/g, '');

就可以解决


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...