49 lines
1.0 KiB
HTML
49 lines
1.0 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<title>代码高亮demo</title>
|
|
</head>
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<!-- 引入css和js -->
|
|
<link rel="stylesheet" type="text/css" href="./styles/monokai-sublime.css">
|
|
<script type="text/javascript" src="./highlight.pack.js"></script>
|
|
<script>hljs.initHighlightingOnLoad();</script>
|
|
|
|
|
|
<!--随便找断代码,放到<pre><code>***</code></pre>之间-->
|
|
|
|
<pre>
|
|
<code>
|
|
|
|
$(document).ready(function(){
|
|
$("ul").each(function(){
|
|
var lis = $(this).find("li");
|
|
for(i in lis){
|
|
var li = lis[i];
|
|
console.log(i);
|
|
if(i == 0){
|
|
$(li).addClass("num_0");
|
|
}else{
|
|
if(i % 4 == 0){
|
|
$(li).addClass("num_"+0);
|
|
}else{
|
|
$(li).addClass("num_"+(i%4));
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
</code>
|
|
</pre>
|
|
|
|
|
|
</body>
|
|
</html>
|