Prevent Highlight of Text Table

后端 未结 7 1943
悲&欢浪女
悲&欢浪女 2020-12-01 01:47

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

7条回答
  •  离开以前
    2020-12-01 01:55

    Just one note on the answer from Cleiton above - the code sample seems to work well, but in order to be a good citizen in the jQuery world, you should return the jQuery object at the end of the function so that it's chainable - a simple one-line addition fixes that up:

    jQuery.fn.extend({
        disableSelection : function() {
                this.each(function() {
                        this.onselectstart = function() { return false; };
                        this.unselectable = "on";
                        jQuery(this).css('-moz-user-select', 'none');
                });
                return this;
        }
    });
    

    Cheers, hope this is helpful.

提交回复
热议问题