如何使用Google-Code-Prettify 实现代码高亮功能
来源:才华咖 本文已影响6.64K人
来源:才华咖 本文已影响6.64K人
导语:如何使用Google-Code-Prettify 实现代码高亮功能,为了方便大家的练习,下面是小编给大家提供的使用方法,大家可以参考阅读,更多详情请关注应届毕业生考试网。
的'使用方法:
1.引入 jQuery 文件和 文件
<script src=""></script>
<script src=""type="text/javascript"></script>
<link href="/" type="text/css" rel="stylesheet" />
2.调用 实现代码高亮
在 body 标签上添加调用方法,如下:
<body onload="prettyPrint()">
</body>
将你需要高亮显示的代码片断放在 pre标记里,如下:
<pre class="prettyprint">
@*你的代码片断*@
</pre>
使用jQuery小技巧实现优化
上述方法可以实现代码的高亮,但每次手动为pre标签添加"prettyprint"类,显示有些麻烦。
使用下边的代码片断来解决这个问题并替换掉 body 的"onload"的事件,实现分离:
$(window)(function(){
$("pre")lass("prettyprint"); prettyPrint();
})
到这我们应该已经成功使用 实现了代码的高亮显示,为了提高页面加载速度,我们应该将引用的js文件放置在底部
Ought Parents to Give Children Pocket英语作文
高中英语作文:My approach to difficulties in learning
用Photoshop如何绘制Google Currents图标
Advice for Good Little Girls大学英语作文
The importance of keep in a good mood英语作文
商务英语阅读: The growing cult of ‘try before you buy’
八年级《unit8 Why don’t you get her a scarf? Period1》评课稿
Identifyingpeoplebyoccupation辨别身份实用英语口语
Modern Technology Makes Life More Conv英语六级作文
Food and place of interest in Beijing初中英语作文
英语作文:Reading Outside The College
英语作文:大学生村官 College Graduates Work as Village Offic
About Respecting the Old高中英语作文
关于智能的英语段落:The dull edge of intelligence
The Unforgettable School Trip英语作文
大学英语作文:Try to Remember the Good Things
英语作文:The Age of Electricity
英语作文The Importance of Self-confidence
如何正确使用html代码
「雅思写作」the Growth Cycle of A Volcanic Island
荣耀属于你们The Glory Belongs to You高中英语作文
Zend studio for eclipse中使php可以调用mysql相关函数的设置方
Choice of large enterprises or small英语四级作文
英语阅读推荐:How to protect cultural identity
A Story Of My Friend Who Ecel大学英语作文
描写飞机的英语作文:the largest carbon footprint
英语美文欣赏:Dont Forget to Wait for Me
Fancy the original or movie ones大学英语作文
World Day to Combat Desertification大学英语作文
How Do My Parents Feel About My Education英语作文
Percent Theory of Life英语美文
高学历如何实现跳槽成功
Jolie drops battle over perfume named Shilohy英语作文
英语作文:The Importance of Self-confidence
A Letter to the Editor of a Newspaper英语四级作文
英语满分作文:Reading-TheBestMeanstoAcquireknowledge
英语作文International Day of Peace Vigil
should women work after getting married英语作文
如何不用代码做游戏课件
如何写代码