move caret to the end of a text input field AND make the end visible

拜拜、爱过 提交于 2019-12-04 09:13:42

I came up with a solution. Webkit (Safari and Chrome) needs a kick in the pants to perform the keyboard event correctly. Add a blur() and then focus() before the backspace:

  textfield.blur(); // Webkit wake-up hack
  textfield.focus();
  textfield.dispatchEvent(e);

Thanks. Works in Safari, Chrome, FF, IE on Mac and Windows now.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!