Javascript jQuery unselectAll() Function

The following function unselects (or deselects) all text on a web page. Include it in your Javascript and just call jQuery.unselectAll().

Readable version

jQuery.unselectAll = function()
{    
    if (document.selection && document.selection.empty) 
    {
        document.selection.empty();
    } 
    else if (window.getSelection) 
    {
        var sel= window.getSelection();
        if(sel && sel.removeAllRanges)
            sel.removeAllRanges();
    }
}

Minified version

jQuery.unselectAll=function(){if(document.selection&&document.selection.empty){document.selection.empty();}else if(window.getSelection){var sel= window.getSelection();if(sel&&sel.removeAllRanges){sel.removeAllRanges();}}}