2010-06-23 171 views

回答

1

而且谷歌上搜索揭晓答案:

if (el.selectionStart != undefined) { 

} 
0

希望这会帮助你。我在旧的Android 4.2(它返回false)和Chrome(它返回true)上测试它。

function selectionSupport() { 
    var input = document.createElement("input"); 
    input.setAttribute('value', '111'); 
    input.selectionStart = 1; 
    input.selectionEnd = 2; 
    return (input.selectionStart === 1 && input.selectionEnd === 2); 
} 

var selectionIsSupported = selectionSupport(); 
相关问题