JavaScript keypress event get end value of textarea

我的未来我决定 提交于 2019-12-05 04:31:23

This will make it work:

input.addEvent( "keypress", function ( input ) {    
    setTimeout(function () {
        input.value // returns the updated value
    }, 0 );    
});

Live demo: http://jsfiddle.net/yQQ5P/ (I use built-in API, as I don't know Mootools)

So, you use a zero-timeout which acts as a yield. This gives the browser's UI thread an opportunity to updated the input's value.

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