在javascript中将样式设置为特定单词

时间:2014-03-09 20:16:37

标签: javascript

我正在使用Milonic菜单的菜单系统,需要在菜单中设置特定的单词来改变风格。例如,在代码中

with(SampStyle=new mm_style()){
bordercolor="#000000";
borderstyle="solid";
borderwidth=0;
fontfamily="Amaranth, sans serif";
fontsize="17px";
fontstyle="normal";
fontweight="normal";
align='center';
offbgcolor="#000000";
offcolor="#ffffff";
onbgcolor="#333333";
oncolor="#ffffff";
pagecolor="#aaffaa";
padding=5;
itemwidth="100px";
}

with(milonic=new menuname("Main Menu")){
alwaysvisible=1;
top=0;
itemwidth="1%";

position:"relative;"
top=230;

/*left=199;*/
screenposition="center";
menuwidth="834px"; /* was 85%, to fit on page 70% -->68% */
/*screenposition="middle;center";
top="offset=-40";*/

orientation="horizontal";
style=SampStyle;
aI("text=Home;url=http://www.moe365.org/;");
aI("showmenu=News;text=News;url=http://moe365.org/news.php;");
aI("showmenu=FIRST Robotics;text=FIRST;url=http://www.moe365.org/whatisfirst.php;");
aI("showmenu=The Team;text=The Team;url=http://moe365.org/team.php;");
aI("showmenu=Media;text=Media;url=http://www.moe365.org/media.php;");
aI("showmenu=Competitions;text=Competitions;url=http://moe365.org/competitions.php;");
aI("showmenu=Robot History;text=Robots;url=http://moe365.org/history.php;");
aI("showmenu=Sponsors;text=Sponsors  ;url=http://moe365.org/sponsors.php;");
aI("showmenu=Resources;text=Resources;url=http://moe365.org/resources.php;");

}

我需要“第一”这个词来改变风格。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

定位单词并在jQuery中使用“.addClass”,如下所示:

/* etc */ 
yourWord.addClass("colorClass");
/* etc */

链接参考: http://api.jquery.com/addclass/

或者将单词包装在这样的span标签中:

<span class="colorClass">FIRST</span>

并在你的CSS中:

.colorClass {
    color:red; /* or the color you want */
}