Accepted answer

Google returned the following result:

The code on that page is

    $.extend($.fn.disableTextSelect = function() {
        return this.each(function(){
            }else if($.browser.msie){//IE
                $(this).bind('selectstart',function(){return false;});
            }else{//Opera, etc.
                $(this).mousedown(function(){return false;});
    $('.noSelect').disableTextSelect();//No text selection on elements with a class of 'noSelect'

In this case, however, you can replace '.noSelect' with '.node', and it should disable text highlighting for all of your nodes.


If you do not want to disable selection of text completely (which is usually much nicer for the user), you can manually deselect an element via selectSubString.

.on("dblclick", function(d) { 
    toggle(d); update(d);
    var text ="text")[0][0]

But this does not yet work cross browser since the SVG API is not yet fully implemeted in many cases. (It works in Chrome at least)

A better cross browser way is to just rewrite the text. This usually also kills the selection:

g.on("dblclick", function(d) {
    toggle(d); update(d);
    var text ="text")
    var value = text.text()

This worked in Firefox and Chrome at least.

Related Query