I'm trying to add a path to an SVG using jQuery, specifically something like $path = $('<path />')
The issue I'm having is that while the svg is created, the path doesn't show in the browser (Chrome). Here is an image and demo:
http://codepen.io/EightArmsHQ/pen/dMNzQW
The red box is the svg, here is the relevant code (all of it is in the codepen)
var connection_css = {
'width' : w + 'px',
'height' : h + 'px',
'background' : 'red',
'position' :'absolute',
'top' : from.top,
'left' : from.left
};
console.log(connection_css);
var $svg = $('<svg />', {
'width':w,
'height':h,
'css' : connection_css
});
var $path = $("<path />", {
'd':"M0 0 L0 " + h +" L"+ w +" "+h,
'stroke':'black',
'stroke-width' : "6",
'fill' : 'transparent'
});
You'll see there is no line. So, the weird bit is that if I copy and paste the DOM element into the HTML, and comment out all my JavaScript
You'll see there is a glorious black line at the bottom of my box. Why isn't this showing when I append it using jQuery?