Posted By

Pjotor on 11/20/14


Tagged

node find traversing D3


Versions (?)

Simpler findNodeByKeyVal


 / Published in: JavaScript
 

URL: http://pjotor.com

If your JSON has child nodes (as in D3 for example).

  1. function findNodeByKeyVal(d, key, val){
  2. var r = []; iC(d);
  3. function iC(c){
  4. (c[key] == val)? r.push(c) : $.grep((c.children||c._children||{}),iC);
  5. }
  6. return r;
  7. }

Report this snippet  

You need to login to post a comment.