我正在尝试使用php-class-html-generator重现以下标记,但我仍然坚持插入<i>
并在最后</h4>
原始HTML
<h4 class="formTitle lead">
<span class="widget-number"><i class="icon-comments"></i></span>Random
</h4>
我的代码:
$h4 = HTMLTag::createElement('h4')->setText("Random")
->addClass('formTitle')
->addClass('lead');
$h4->addElement('span')
->addClass('widget-number');
return($h4);
我目前的输出:
<h4 class="formTitle lead">
<span class="widget-number">Random</span>
</h4>
谢谢你的帮助!
答案 0 :(得分:3)
试试这个 -
$h4 = HTMLTag::createElement('h4')->setText("Random")->addClass('formTitle')->addClass('lead');
$span = $h4->addElement('span')->addClass('widget-number');
$i = $span->addElement('i')->setText(' ')->addClass('icon-comments');
结果 -
<h4 class="formTitle lead">
<span class="widget-number">
<i class="icon-comments"></i></span>Random</h4>