jQuery鼠标悬停禁用了在密码结束时按回车键的功能

jQuery mouseover disables ability to hit return at end of password to login

本文关键字:回车 功能 结束 密码 悬停 鼠标 jQuery      更新时间:2023-09-26

PeopleSoft的浏览器选择Internet Explorer,但不支持:hover。为了模拟:悬停在登录按钮上,我添加了以下脚本:

$(function(){
    $(".fg-button:not(.ui-state-disabled)")
    .hover(
    function(){ 
            $(this).addClass("ui-state-hover"); 
        },
        function(){ 
            $(this).removeClass("ui-state-hover"); 
        }
    )
    .mousedown(function(){
            $(this).parents('.fg-buttonset-single:first').find(".fgbutton.ui-stat e-active").removeClass("ui-state-active");
        if( $(this).is('.ui-state-active.fg-button-toggleable, .fg-buttonset-multi .ui-state-active') ){ $(this).removeClass("ui-state-active"); }
        else { $(this).addClass("ui-state-active"); }   
    })
    .mouseup(function(){
        if(! $(this).is('.fg-button-toggleable, .fg-buttonset-single .fg-button, .fg-buttonset-multi .fg-button') ){
        $(this).removeClass("ui-state-active");
        }
    });
});

与下面的html

    <button class="fg-button ui-state-default ui-corner-all" type="button" name="Submit" onClick="submitAction(document.login)">Sign In</button>

只是现在,而不是按enter一旦你已经完成了你的密码,你就会自动登录,而不需要像许多开发人员那样点击登录按钮-你现在必须点击登录按钮来启动登录过程。这给那些不想点击"登录"按钮的人造成了很大的困扰。没有好的无障碍行为不受惩罚。

完整的代码在http://jsfiddle.net/maniator/2NCHd/1/

IE 7及更高版本支持:悬停在任意元素上,只要浏览器处于标准模式而不是古怪模式——只要确保启用了正确的文档类型。

如果你还支持ie6,我很同情你。在这种情况下,您可以尝试添加whatever:hover浏览器行为。就我个人而言,在这种情况下,我会切换到严格的文档类型以支持ie7 +,并使用条件注释将浏览器行为仅应用于ie6。

并且,正如@mootinator在上面评论的那样,您总是可以添加更多的JavaScript来触发表单提交,当焦点在表单字段中时,有人按enter键。