I have a table, and I\'m allowing users to \'select\' multiple rows. This is all handled using jQuery events and some CSS to visually indicate the row is \'selected\'. When
If you want to have control when your users can select or not parts of you site, you can use this little jQuery plugin.
jQuery.fn.extend({
disableSelection : function() {
return this.each(function() {
this.onselectstart = function() { return false; };
this.unselectable = "on";
jQuery(this).css('user-select', 'none');
jQuery(this).css('-o-user-select', 'none');
jQuery(this).css('-moz-user-select', 'none');
jQuery(this).css('-khtml-user-select', 'none');
jQuery(this).css('-webkit-user-select', 'none');
});
}
});
and use it as:
// disable selection on #theDiv object
$('#theDiv').disableSelection();
Otherwise, you can just use these css attributes inside your css file as:
#theDiv
{
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}