javascript - jQuery create element by template <element /> -
i can create new element jquery:
var $e = $("<element>");
the result after appending be:
<element></element>
but need:
<element/>
how reach desirable result? example, how create:
<path id="p2" d="m0,0"/>
i tried $("<path/>")
, $("<path />")
, not works. believe, that:
$("#parent").html("<path id='p2'/>"); var $p = $("#p2"); $p.attr({'d': "m0,0"}); ...
will work, nightmare me
update 1:
even $("#parent").html("<group><path id='p2'/></group>");
not working! produces:
<... id="parent"><group><path id='p2'></path></group></...>
update 2:
even $parent[0].innerhtml = '<group><path id="p1"/></groups>';
produces:
<... id="parent"><group><path id='p2'></path></group></...>
$("#parent").html("<path id='p2'/>");
if in above statement want value display of ` in tag or attribute id='parent', has following:
$("#parent").html(document.getelementbyid('p2'));
javascript jquery xhtml
No comments:
Post a Comment