This is really a nasty case, because you cannot use the DOM selector directly on embedded documents. Basically, you need the selector "#circles > circle" , but in this case it will not work. So you need something pretty ugly like
var my_circles = d3.select(document.getElementById("circles").contentDocument) .selectAll("circle");
I find the Javascript console quite useful for debugging selectors. Just enter what you want to check and see if the things you want are back.
The problem is that the above code only works after the object has been loaded. Even when using something like jQuery .ready() this is not enough. A quick and dirty solution is to repeatedly check if the elements are present until they are:
function changeColor() { var sel = d3.select(document.getElementById("circles").contentDocument) .selectAll("circle"); if(sel.empty()) { setTimeout(changeColor, 100); } else { sel.attr("fill", "black"); } } changeColor();
Full example here .
source share