最近在做一个根据光标位置改变数值的功能,使用document可以获取textarea的光标位置,但是textarea不能限制输入内容只能为数字, const input = document.getElementById(this.id).getElementsByTagName("textarea")[0]; console.log(input); console.log(input.selectionStart);