当我在Chrome上单击禁用的输入时,它给了我想要的结果,但是在Mozilla中,由于禁用了类,它没有呈现任何内容。我该怎么做才能使其正常工作?

<head>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script>
        $(document).ready(function(){
            $(".divclick").click(function(){
                alert("jsk");
            });
        });
    </script>
</head>
<body>
    <div class="divclick" height="100px" width="100px" style="background:red;">
        <input type="text" disabled>
    </div>
</body>

附言:已经尝试在其周围放置 wrapper 。我只希望所需的输入

最佳答案

我遇到了这个线程https://bugzilla.mozilla.org/show_bug.cgi?id=218093

Firefox, and perhaps other browsers, disable DOM events on form fields that are disabled.
Any event that starts at the disabled form field is completely canceled and does not propagate up the DOM tree.
Correct me if I'm wrong, but if you click on the disabled button,
the source of the event is the disabled button and the click event is completely wiped out.
The browser literally doesn't know the button got clicked, nor does it pass the click event on.
It's as if you are clicking on a black hole on the web page.

来源在这里Click event doesn't fire for disabled text field?

这是Demo

关于javascript - 单击(禁用)输入未在Mozilla上触发,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20898344/

10-11 13:33
查看更多