I want to prevent input focus onclick and focus inputs on double click.
Something like....
$('input').click(function) {
$(this)preventFocus();
});
$('input').dblclick(function) {
$(this)focus();
});
Or maybe I should use an if statement?
I want to prevent input focus onclick and focus inputs on double click.
Something like....
$('input').click(function) {
$(this)preventFocus();
});
$('input').dblclick(function) {
$(this)focus();
});
Or maybe I should use an if statement?
I guess something like this should work :
$('input').on({
focus: function() {
if (!$(this).data('disabled')) this.blur()
},
dblclick: function() {
$(this).data('disabled', true);
this.focus()
},
blur: function() {
$(this).data('disabled', false);
}
});
You could try something like the following
HTML:
<input type="text" id="myInput" readonly="readonly" />
jQuery:
$("#myInput").dblclick(function(){
$(this).prop("readonly", false)
});
$("#myInput").blur(function(){
$(this).prop("readonly", true);
});