【发布时间】:2013-05-23 15:06:42
【问题描述】:
我正在尝试构建一个 HTML 元素库(例如 Twitter Bootstrap),并且我希望在正确的代码标记旁边有一个实时版本的元素(例如按钮)。
我正在尝试使用Prettify 来显示类似<button>Button</button> 的内容,但它似乎不起作用。
以下是我查看页面时看到的内容:
问题:我在这里做错了什么?
以下是相关的 HTML:
<html>
<head>
<title>Common HTML Library</title>
<link type="text/css" rel="stylesheet" href="common.css" />
<link type="text/css" rel="stylesheet" href="prettify/prettify.css" />
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="prettify/prettify.js"></script>
<script type="text/javascript">
$(document).ready(function() {
prettyPrint();
});
</script>
</head>
<body>
<h1>Buttons</h1>
<table>
<thead>
<tr>
<th>Element</th>
<th>Description</th>
<th>Markup</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<button>Button</button>
</td>
<td>Standard Button</td>
<td>
<code class="prettyprint">
<button>Button</button>
</code>
</td>
</tr>
<tr>
<td>
<button class="primary">Button</button>
</td>
<td>Primary Button</td>
<td>
<code class="prettyprint">
<button class="primary">Button</button>
</code>
</td>
</tr>
<tr>
<td>
<button disabled="disabled">Button</button>
</td>
<td>Disabled Button</td>
<td>
<code class="prettyprint">
<button disabled="disabled">Button</button>
</code>
</td>
</tr>
</tbody>
</table>
</body>
</html>
编辑:
我尝试设置语言并像这样使用<pre> 并得到以下结果:
<pre class="prettyprint lang-html">
<button>Button</button>
</pre>
【问题讨论】:
标签: jquery html pre pretty-print