Reputation: 823
Really simple question but how do you select all unselected nodes ? I have nodes classed as .selectedNode, how do I select the inverse (everything else).
d3.selectAll(".selectedNode")
What I want to do is apply a class to all unselected nodes to hide the, : visibility:hidden
Upvotes: 0
Views: 427
Reputation: 476
Try to use the selector ":not" :
d3.selectAll("div:not(.selectedNode)").style("display", "none");
<div class="selectedNode"> <h4>Selected Node 1<h4> </div>
<div class="selectedNode"> <h4>Selected Node 2<h4> </div>
<!-- this div will be hide -->
<div class="unSelectedNode"> <h4> Unelected Node 3<h4> </div>
<div class="selectedNode"> <h4>Selected Node 4<h4> </div>
<div class="selectedNode"> <h4>Selected Node 5<h4> </div>
You can try it right now : http://jsfiddle.net/Bentayaa/dcavpdbr/
I hope that will help.
Best regards
Upvotes: 2
Reputation: 823
Here is how I solved it :)
nodes.classed("hidden", function (d)
{
return d.selected ? false : true;
});
Basically says if its selected dont give it the hidden class but if it isnt selected give it the hidden class :)
Upvotes: 2