0

次のような非常に単純なコードがあります

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title><style>span {display:none;}  </style>
</head>
<body>

  <p><input type="text" id="a"/> <span>focus fire</span></p>

<p><input type="password" /> <span>focus fire</span></p>


  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>


<script>

    $("input").focus(function () {

        $(this).next("span").css('display', 'inline').fadeOut(1000);
        alert("he");
    });

    $(function () {
        $("#a").focus();
    });
</script>

</body>
</html>

Chrome と Safari では、alert が発火し続けますが、IE、FF、Opera と比較すると、一度しか発火しません。誰かがこれを説明できますか?

4

1 に答える 1

0

これは、アラートが閉じられた後、Chrome と Safari が再び要素にフォーカスし、別のアラートが発生するなどの理由によるものです。他のブラウザは、アラートが消えた後は何にも注意を向けません。

于 2013-08-18T14:59:21.270 に答える