1
這裏是我嘗試建立社交圈:顯示爲什麼從JavaScript創建的svg元素不可見?
,最初硬編碼有var svgns = "http://www.w3.org/2000/svg/";
var circle = function(x, y) {
this.x = x;
this.y = y;
this.element = document.createElementNS(
svgns, "circle"
);
this.element.setAttributeNS(null, "cx", x);
this.element.setAttributeNS(null, "cy", y);
this.element.setAttributeNS(null, "r", CIRCLE_RADIUS);
this.element.setAttributeNS(null, "fill", randomColor());
svg.appendChild(this.element);
}
circle(100, 100);
只有一圈。兩另一個 這是我的腳本添加是不可見的,但它們幾乎identica,如種子DevTools:
這裏是鏈接CodePen。也許我搞砸了一些命名空間或風格什麼的?
對於那些誰也看不出來區別 - >'/'在最後被刪除 – Weedoze
這是正確的 –