tags:

views:

219

answers:

2

Hi guys, how can I add a string in an empty font tag? Like if in the second font tag there is no value, I will just insert a <br /> tag. How can I do that?

Thanks :)

I have this HTML code:

<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>

And I like the output to be:

<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>
A: 

something like

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

or append:

$("font:empty").append("My string");
Sergei
+5  A: 

You shouldn't be using a font tag.

You can

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

in PHP or

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

in jQuery.

Antony Carthy
Thanks antony. I will try both of your solutions :D
marknt15
It worked Antony thanks :)
marknt15