I can't see your example, but if you using JS to append a html element to svg, you must remember using prefix to tell browser that this element is svg or html.
For example, if you append a html img element:
$('svg').append('svg:foreignObject').append('xhtml:img').attr('src','./foo.jpg');