tags:

views:

48

answers:

1

Hi,

I have the following jQuery code that stops the user selecting text in a table element.

$('table').live("selectstart", function(e) {
    e.preventDefault();
});

This works in IE, but not in Firefox. How can I get this to work in Firefox?

Thanks

+3  A: 

Try this,

if($.browser.mozilla){//Firefox
    $('table').css('MozUserSelect','none');
}else if($.browser.msie){//IE
   $('table').live("selectstart", function(e) {
      e.preventDefault();
    });
}else{//Opera, etc.
   $('table').mousedown(function(){return false;});
}

Or use this plugin: http://chris-barr.com/entry/disable%5Ftext%5Fselection%5Fwith%5Fjquery/

Henrik Adolfsson