javascript - Cannot read property 'nodeName' of undefined in SVG file -
that error caused script executed before end of loading of page explain here : cannot read property childnodes of null
but don't think it's error here :
<?xml version="1.0" encoding="utf-8"?> <!doctype svg public "-//w3c//dtd svg 1.1//en" "http://www.w3.org/graphics/svg/1.1/dtd/svg11.dtd"> <svg onload="init(evt)" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"> <script xlink:href="jquery-1.10.2.min.js"/> <script xlink:href="test.js"/> <g id="id"> </g> </svg>
and test.js file :
function init () { $(document).mousedown(test) } function test (evt) { $('#id').append('test'); $('#id').append('<rect x=10 y=10 width=50 height=50/>'); }
what curious first appending works not second one. error raise when there <
in string... why ?
if instantiate element via jquery $('<tag_name/>')
method, works.
function test (evt) { $('#id').append('test'); $('#id').append($('<rect/>').attr({'x':10,'y':10,'width':50,'height':50})); }
Comments
Post a Comment