网页代码段高亮显示

首先引入JS和样式:

<link href="http://cdn.bootcss.com/highlight.js/8.0/styles/monokai_sublime.min.css" rel="stylesheet">
<script src="http://cdn.bootcss.com/highlight.js/8.0/highlight.min.js"></script>



然后在底部加入:

<script>
//代码高亮
$(function(){
$('pre code').each(function(i, block) {
hljs.highlightBlock(block);
});
});

</script>


快捷回帖