Accepted answer

You can filter a selection with .filter(). In your case, this would look something like this.

var selected = circle.filter(function(d) {
         return == "Amazon" || == "Foxconn";

Now you can operate on that selection, where this will be the circle elements and the data is accessible in the usual way.

selected.each(function(d) {
  // d contains the data for the node and this is the circle element


when you use enter() to append node, i think you should add some attribute to label the

node such as a id

<!doctype html>
<html lang="zh">
    <meta charset="utf-8">
    <title>Template Index</title>

  <ul id="comp">

    <script src=""></script>
  var company = [
    { id: "IBM", value: "222"},
    { id: "MS", value: "222"},
    { id: "Google", value: "222"}
  var comp ="#comp").selectAll(".com")
    .attr("id", function (d) { return "id" +; })
    .text(function (d) { return; });

  var ibm ="#idIBM").datum();
  console.log(ibm); // Object { id="IBM", value="222"}

then you can get the selection throw d3

then get the object data binded in selection by datum()

update: i update the file and tested in firefox chrome and ie10 it works well

Related Query