开发者

How can I pause jQuery until a condition is met?

开发者 https://www.devze.com 2023-02-07 10:00 出处:网络
The condition is that a SPACE is typed.... It\'s inside a CASE sta开发者_如何学JAVAtement: case KEY.ATSIGN:

The condition is that a SPACE is typed.... It's inside a CASE sta开发者_如何学JAVAtement:

        case KEY.ATSIGN:

                        clearTimeout(timeout);
                        //alert(event.keyCode);
                        while(event.keyCode != 32) {
                            alert(event.keyCode);
                            timeout = setTimeout(onChange, options.delayLong);

                        }

            break;

32 is the ascii for space... I am trying to get the subset matching feature to work in jQuery only AFTER an @ sign is typed.... Hence the case statement KEY.ATSIGN.


You can put an event handler on the keypress event on your input element and evaluate what key was pressed.

http://api.jquery.com/keypress/

0

精彩评论

暂无评论...
验证码 换一张
取 消