score:1
Google returned the following result: http://chris-barr.com/index.php/entry/disable_text_selection_with_jquery/
The code on that page is
$(function(){
$.extend($.fn.disableTextSelect = function() {
return this.each(function(){
if($.browser.mozilla){//Firefox
$(this).css('MozUserSelect','none');
}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.
score:0
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 = d3.select(this).select("text")[0][0]
text.selectSubString(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 = d3.select(this).select("text")
var value = text.text()
text.text(value)
})
This worked in Firefox and Chrome at least.
Source: stackoverflow.com
Related Query
- D3 Tree node double click highlights text
- How can I make double click event on node in d3.js?
- Add hyperlink to node text on a collapsible tree
- javascript zoomable tree map click the last node
- Trying to append a click function to the node text in d3
- Both single and double click on a node in d3 force directed graph
- how to distinguish between single mouse click and double click on same node element in d3 js
- D3 Tree node on click
- d3 - drag node groups in radial tree layout without jumping to new position on click
- On click of parent node in tree layout, Like link and node, linkText should also exit
- How do I prevent node text to move away or not overlap on my tree in D3.js?
- d3 force directed graph, focus on node double click
- How to achieve double click in Tree in D3.js?
- Assigning HTML Link to Tree Node Text
- Increase spacing/padding between each nodes in D3 Collapsible tree chart to avoid node and text overlaping
- Draw graph for child nodes on click of the node of tree pattern in d3.js
- D3 - Dynamically change text of node in tree when pressing a button
- d3.js radial tree layout variable node length / text wrap node description
- d3js tree layout node click event
- D3.js tree - Very long text on first node
- How to disable double click zoom for d3.behavior.zoom?
- Add text label to d3 node in Force directed Graph and resize on hover
- Show d3 node text only on hover
- Add Node to D3 Tree v4
- Add text label to d3 node in Force layout
- how to display name of node when mouse over on node in collapsible tree graph
- D3 Selecting based on text value of node
- Prevent click action when dragging a D3 Node
- I want to add text on the link in D3.js tree graph
- Recentering D3 force layout diagram on node click
More Query from same tag
- How to delay a loop? Or how to make a loop slower?
- Scatter Chart in analog clock
- JavaScript variable assignment/return
- D3.time scale keeps returning default value
- How to convert a chart with kernel density estimation line from d3.js version 3 to d3.js version 4
- d3 tracking overlay multiple lines
- Why is d3.histogram merging the last two bins of this chart?
- How to change transition duration globally in NVD3?
- D3 Bar Chart Troubleshooting
- DimpleJS barchart styling columns
- D3 labels issue in zoomable scatter plot
- Map function in D3, confused about multiple functions passed in
- Cannot read property 'map' of undefined using D3 Bar Chart in Angular 7
- making d3.js compatible with ie
- local vs global variable in Javascript
- D3 transitions with multiple graphs
- Proper format for drawing polygon data in D3
- Update size and value of multiple donut charts d3.js
- How to mark discrete points on a time series graph using D3 / Rickshaw?
- D3.tip is not a function
- D3 : get value from the array
- nvd3 - multiBarChart: how to log scale y axis
- Nested data with D3.js
- d3 multi-line voronoi, trouble with showing data on mouseover
- D3 nodes overlapping
- D3 module on Drupal doesn't show examples
- How to load a json from externally to a D3 application
- Show a custom tooltip on mouseover of the node (force directed d3 graph)
- Setting multiple img alt listeners with jquery/javascript
- How to select single class name from multiple using d3 js?