marcusshepp
6/21/2016 - 6:37 PM

clear selection on an element if it gets highlighted

clear selection on an element if it gets highlighted

function clear_selection() {
    /*  
    I use this to ensure the `next` and `prev` buttons don't
    stay highlighted when clicking quickly.
    */
    if(document.selection && document.selection.empty){
        document.selection.empty();
    } else if (window.getSelection){
        var sel = window.getSelection();
        sel.removeAllRanges();
    }   
}