0
我有以下D3代碼我想CSS添加到其中:如何使用jQuery更改創建的D3對象的CSS?
// Update the links…
var link = vis.selectAll("path.link")
.data(tree.links(nodes), function(d) { return d.target.id; });
// Enter any new links at the parent's previous position.
link.enter().insert("svg:path", "g")
.attr("class", "link")
.attr("d", function(d) {
var o = {x: source.x0, y: source.y0};
return diagonal({source: o, target: o});
})
.transition()
.duration(duration)
.attr("d", diagonal);
// Transition links to their new position.
link.transition()
.duration(duration)
.attr("d", diagonal);
link.style("stroke", function(d, i){
console.log();
if((i == ((link.size()/2)-1) || i == ((link.size()/2)-2)) && (AMLsIncluded == true)){
return "white";
}
});
我使用下面的代碼更改CSS,但沒有任何反應:
$(".link path").css({"fill":"none", "stroke":"#ccc", "stroke-width":"1.5px"});
難道我抓住路徑。鏈接正確的方式?我曾經讓我的css在一個單獨的.css文件中,但由於多種原因,我需要使它變成動態的。從CSS文件導入時可以使用:
path.link {
fill: none;
stroke: #ccc;
stroke-width: 1.5px;
}
我在做什麼錯?