单击(禁用)输入未在Mozilla上触发

时间:2014-01-03 07:01:30

标签: javascript jquery

当我在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>

Ps:已经尝试过在它周围放一个包装器。我只希望得到所需的输入

1 个答案:

答案 0 :(得分:0)

我遇到了这个帖子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