我想防止输入焦点 onclick 和焦点输入双击。
就像是....
$('input').click(function) {
$(this)preventFocus();
});
$('input').dblclick(function) {
$(this)focus();
});
或者也许我应该使用 if 语句?
我想防止输入焦点 onclick 和焦点输入双击。
就像是....
$('input').click(function) {
$(this)preventFocus();
});
$('input').dblclick(function) {
$(this)focus();
});
或者也许我应该使用 if 语句?
我想这样的事情应该有效:
$('input').on({
focus: function() {
if (!$(this).data('disabled')) this.blur()
},
dblclick: function() {
$(this).data('disabled', true);
this.focus()
},
blur: function() {
$(this).data('disabled', false);
}
});
您可以尝试以下内容
HTML:
<input type="text" id="myInput" readonly="readonly" />
jQuery:
$("#myInput").dblclick(function(){
$(this).prop("readonly", false)
});
$("#myInput").blur(function(){
$(this).prop("readonly", true);
});