You can't use createElement to create SVG elements. SVG elements must be created in the SVG namespace so you need to write
document.createElementNS("http://www.w3.org/2000/svg", "tspan");
There is a jquery plugin which adds functionality to jquery allowing svg elements to be created.