If you want to avoid plugins, you can extract the relevant parts from the jQuery user interface source:
$.support.selectstart = "onselectstart" in document.createElement("div"); $.fn.disableSelection = function() { return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) + ".ui-disableSelection", function( event ) { event.preventDefault(); }); }; $("#somediv").disableSelection();
source share