单击(禁用)输入未在 Mozilla 上触发 [英] Click on (disabled) input not getting triggered on Mozilla

查看:29
本文介绍了单击(禁用)输入未在 Mozilla 上触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我点击 Chrome 上禁用的输入时,它给了我想要的结果,但在 Mozilla 中,由于禁用类,它没有呈现任何内容.我该怎么做才能让它发挥作用?

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script><脚本>$(document).ready(function(){$(".divclick").click(function(){警报(jsk");});});<身体><div class="divclick" height="100px" width="100px" style="background:red;"><input type="text" 已禁用>

Ps:已经试过在它周围放一个包装纸.我希望只有所需的输入

解决方案

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

Firefox,或许还有其他浏览器,会在已禁用的表单字段上禁用 DOM 事件.在禁用的表单字段开始的任何事件都被完全取消并且不会向上传播 DOM 树.如果我错了,请纠正我,但是如果您单击禁用按钮,事件的来源是被禁用的按钮,点击事件被完全清除.浏览器实际上并不知道按钮被点击了,也不会传递点击事件.就好像你在点击网页上的一个黑洞.

来源在这里 点击事件不会触发对于禁用的文本字段?

这是演示

When I click on a disabled input on Chrome it's giving me the desired results but in Mozilla due to the disabled class, it isn't rendering anything. What do I do to make it work?

<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: already tried putting a wrapper around it. I wish only the desired Input

解决方案

I came across the this thread 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.

Source is here Click event doesn't fire for disabled text field?

Here is the Demo

这篇关于单击(禁用)输入未在 Mozilla 上触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆