Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Click on (disabled) input not getting triggered on Mozilla

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

like image 469
Saurabh Dosi Avatar asked Jan 03 '14 07:01

Saurabh Dosi


1 Answers

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

like image 56
dhana Avatar answered Sep 30 '22 08:09

dhana