php - How to insert a node as parent of another node -
php - How to insert a node as parent of another node -
this question has reply here:
wrap images div using domdocument 1 replyi want add together node parent of existing node. say, html code follows
<p>my tag</p> <img src='somesrc.png'/> ... ... i want add together anchor parent img node resulting in next code
<p>my tag</p> <a href='somelink'><img src='somesrc.png'/></a> ... ... i haven't found in domdocument can add together node parent of node. there appendchild() method adding child, there nil add together parent directly. best way solve problem?
if you're using jquery can utilize wrap.
if want utilize native javascript best approach to other way around - create anchor , utilize appendchild move img element since appendchild move element when in dom.
oops, wrong api. sorry. reply pretty much same. create anchor, utilize replacechild set img , move img anchor.
php domdocument
Comments
Post a Comment