Disabled elements, such as <select>and <input>, do not respond to the click event, I try to wrap them in <div>and listen to its click event.
By clicking on the disabled <input>, a click on it starts in the container <div>, but I have a problem with the elements <select>. pressing a disabled item <select>does not call its container <div>, as you can see in this JSFiddle example .
HTML:
<button onclick="buttonClick()" >Click</button>
<div id="test"></div>
JS:
buttonClick = function (){
var editor = $("#test");
var div=$("<div>")
.mousedown(function () {
alert("!!!");
})
.appendTo(editor);
var selecttest = $("<select>")
.attr("disabled", "disabled")
.appendTo(div);
$("<option />").attr("value", '').appendTo(selecttest);
};
If I add <input>using the following code instead <select>, it will work:
var textinput = $("<input>")
.attr("type", "text")
.attr("disabled", "disabled")
.appendTo(div);
Tests for different browsers: For IE11: for inputand selectit works.
For Firefox: for inputand selectit does not work.
Opera Chrome: input , select .