$('input').on('focus', function() {
$(this).val('example');
$(this).attr('unselectable', 'on').css('user-select', 'none').on('startselect', false);
});
当我尝试在 Chrome 或 Opera 上选择字段值时,我可以做到这一点。在 Firefox 和 IE 上很好。
有什么方法可以禁用输入字段中的文本选择?
IE 10、Chrome 30、Opera 17。
来源:http: //jsfiddle.net/VmDDY/