简体   繁体   English

jQuery,Opera。 如何停止提交?

[英]Jquery, Opera. How to stop submit?

i'm using this control http://devthought.com/projects/mootools/textboxlist/ 我正在使用此控件http://devthought.com/projects/mootools/textboxlist/

It's using JQuery 它正在使用JQuery

Code: 码:

bit.toElement().keydown(navigate);
 var navigate = function (ev) {
    var evStop = function () {
        ev.stopPropagation();
        ev.preventDefault();
    };

    switch (ev.which) {
    case 13:
        evStop();

        ...work...
    }
};

This code work fine in FF and IE, on pushing Enter it's stop form submit. 该代码在FF和IE中可以正常工作,按Enter即可停止表单提交。

Q: But in Opera, page reload, how to fix that? 问:但是在Opera中,页面重新加载如何解决?

Solution: bit.toElement(). 解决方案: bit.toElement()。 keypress (navigate); 按键 (导航);

Perhaps, you could include a "return false", to the function. 也许,您可以在函数中包含“ return false”。

In case, this works. 万一这可行。

Try to change "keydown" by "keypress". 尝试通过“ keypress”更改“ keydown”。

Try this: 尝试这个:

$(document).bind("keydown keypress", function(event) then e.preventDefault() won't work try.. event.preventDefault() 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM