使用jquery 默认创建的是dom元素而不是svgdom,给用createElementNS方法创建,以<rect>标签为例:
var svgNS = 'http://www.w3.org/2000/svg'
var oSvg = document.createElementNS(svgNS, 'rect')
// 为rect标签添加属性
oSvg.setAttribute('x', location.x - container.x)
oSvg.setAttribute('y', location.y - container.y)
oSvg.setAttribute('width', location.width - 4)
oSvg.setAttribute('height', location.height)
// 将rect标签添加至svg标签内
$('#svg-container').append(oSvg)