首页 > 代码库 > 输出字体颜色 "<li><font color=red>" + ......+ "</font>"

输出字体颜色 "<li><font color=red>" + ......+ "</font>"

<title>4-15</title>
<script language="javascript">
<!--
    var students = new Array( "杨宗楠", "杨玉婷", "李莉" );
    for( index in students )
    {
        if( students[index] != "杨宗楠" )     //不是“杨宗楠”就输出为黑色字体
        {
            document.write( "<li>" + students[index] )
        }
        else                                // 是杨宗楠输出为红色字体
        {
            document.write( "<li><font color=red>" + students[index] + "</font>" );
        }
    }
-->
</script>

out:

技术分享

 

输出字体颜色 "<li><font color=red>" + ......+ "</font>"