Ashung给我看他的08年写的一个”web font v 0.3“的页面,偶也用jquery小玩了一下,嘿嘿,在线演示。

//定义font size
var fontSizeJson = {fontSize:["small","medium","large","x-large","xx-large","x-small",
"xx-small","11px","12px","13px","14px","15px","16px",
"17px","18px","8pt","9pt","10pt","11pt","12pt","13pt",
"14pt","15pt"]};
//定义font family
var fontFamilyJson = {fontFamily:["Arial","Bitstream Charter","Bitstream Vera Sans",
"Bitstream Vera Sans Mono","Bitstream Vera Serif",
"Book Antiqua","Bookman Old Style",
"Calibri","Cambria","Candara",
"Century","Century Gothic","Comic Sans MS","Consolas",
"Constantia","Corbel","Courier","Courier New",
"FreeMono","FreeSans","FreeSerif",
"Garamond","Geneva","Georgia",
"Helvetica","Helvetica Neue","Impact",
"Lucida Bright","Lucida Console","Lucida Sans","Lucida Sans Unicode",
"Microsoft Sans serif","Optima",
"Palatino Linotype","Tahoma","Times New Roman",
"Timmons","Trebuchet MS","Univers","Utopia","Verdana",
"SimSun", "SimHei", "Arial Unicode MS", "Microsoft Yahei",
"Microsoft JhengHei","Meiyo","Malgun Gothic","Segoe UI"]};
//定义段落
var paragraph = "Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an
unknown printer took a galley of type and scrambled it to make a type specimen book. It
has survived not only five centuries, but also the leap into electronic typesetting, remaining
essentially unchanged. 1234567890 ";
//循环输出不同font family的模块
$.each(fontFamilyJson.fontFamily,function(n,value){
$("#content").append(String.format("<div class='section' style='font-family:{0}'>
<h3>{0}</h3>
<p>{1}</p></div>",value,paragraph));
});
//循环输出font size的菜单
$.each(fontSizeJson.fontSize,function(n,value){
$("#nav").append(String.format("<a href='#'>{0}</a>",value));
});
$("#nav a").click(function(){
$(".section").css("font-size",$(this).text());
return false;
});
有2 位同学留下了脚印
哇,真神奇啊···这样都行···
好文,JQUERY真是个好东西。