如何在空字体标记中插入字符串?

时间:2009-05-18 07:26:56

标签: php

如何在空字体标记中添加字符串?就像在第二个字体标记中没有值一样,我只会插入一个<br />标记。我怎么能这样做?

我有这个HTML代码:

<P ALIGN="LEFT">
    <FONT FACE="Verdana" style="font-size:10" COLOR="#0B333C" LETTERSPACING="0" KERNING="0">
        Welcome to jQuery Course
    </FONT>
</P>
<P ALIGN="LEFT">
    <FONT FACE="Verdana" style="font-size:10" COLOR="#0B333C" LETTERSPACING="0" KERNING="0">
    </FONT>
</P>
<P ALIGN="LEFT">
    <FONT FACE="Verdana" style="font-size:10" COLOR="#0B333C" LETTERSPACING="0" KERNING="0">
        This is the jQuery Introduction content.
    </FONT>
</P>

我喜欢输出:

<P ALIGN="LEFT">
        <FONT FACE="Verdana" style="font-size:10" COLOR="#0B333C" LETTERSPACING="0" KERNING="0">
            Welcome to jQuery Course
        </FONT>
    </P>
    <P ALIGN="LEFT">
        <FONT FACE="Verdana" style="font-size:10" COLOR="#0B333C" LETTERSPACING="0" KERNING="0">
            <br />
        </FONT>
    </P>
    <P ALIGN="LEFT">
        <FONT FACE="Verdana" style="font-size:10" COLOR="#0B333C" LETTERSPACING="0" KERNING="0">
            This is the jQuery Introduction content.
        </FONT>
    </P>

2 个答案:

答案 0 :(得分:5)

您不应该使用字体标记。

你可以

str_replace("></FONT>", ">$myinserttext</FONT>", $myhtml);
PHP中的

$("font:empty").html("Sample Content");

在jQuery中。

答案 1 :(得分:0)

类似

$("font:empty").html("My string");

or append:

$("font:empty").append("My string");