[js]火狐中选中contenteditable的全部文本无法进一步编辑

代码

function selectElementContents(el) {
        var range = document.createRange();
        range.selectNodeContents(el);
        var sel = window.getSelection();
        sel.removeAllRanges();
        sel.addRange(range);
    }
    
    var foo = function(){
        var el = document.getElementById("hello");
        selectElementContents(el);  
    }

参考文献

http://stackoverflow.com/questions/6139107/programatically-select-text-in-a-contenteditable-html-element

你可能感兴趣的:([js]火狐中选中contenteditable的全部文本无法进一步编辑)