Simple HTML Dom Parser: How to insert to elements

前端 未结 1 1783
鱼传尺愫
鱼传尺愫 2021-02-10 11:38

I am trying to insert (append) into an element ... \"body\" specifically.

I am able to do this this way at the moment:

$var = \"some JS stuff\";
$e = $ht         


        
1条回答
  •  不知归路
    2021-02-10 11:41

    After looking at the source code, I found that the way to go about it is to use

    $var = "some JS stuff";
    $e = $htmlDOM->find("body", 0);
    $e->outertext = $e->makeup() . $e->innertext . $var . '';
    

    That is, the undocumented makeup() function will build the tag and any associated text/code.

    0 讨论(0)
提交回复
热议问题