javascript - Event on a disabled input -
apparently disabled <input>
not handled event
is there way workaround issue ?
<input type="text" disabled="disabled" name="test" value="test" />
$(':input').click(function () { $(this).removeattr('disabled'); })
here, need click on input enable it. if don't activate it, input should not posted.
disabled elements don't fire mouse events. browsers propagate event originating disabled element dom tree, event handlers placed on container elements. however, firefox doesn't exhibit behaviour, nothing @ when click on disabled element.
i can't think of better solution but, complete cross browser compatibility, place element in front of disabled input , catch click on element. here's example of mean:
<div style="display:inline-block; position:relative;"> <input type="text" disabled /> <div style="position:absolute; left:0; right:0; top:0; bottom:0;"></div> </div>
jq:
$("div > div").click(function (evt) { $(this).hide().prev("input[disabled]").prop("disabled", false).focus(); });
example: http://jsfiddle.net/rxqam/170/ (updated use jquery 1.7 prop
instead of attr
).
Comments
Post a Comment