一段想用SyntaxHighlighter高亮的代码,却被jQueryUI给初始化了
这段是想展示的代码
<pre class="brush: xml">
<p class="area">
<p class="buttonset">
<input type="radio" id="unit-1" name="unit" checked="checked" /><label for="unit-1">天</label>
<input type="radio" id="unit-2" name="unit" /><label for="unit-2">小时</label>
</p>
</p>
</pre>
网页中包含如下正常的初始化脚本
$('.buttonset').buttonset();
这段初始化JS,怎么连<pre>标签内部的元素也给我处理了,这怎么办?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
方案一:
SyntaxHighlighter.all(); setTimeout(function(){ $('.buttonset').buttonset(); }, 0);方案二(推荐方案):
使用<script type="syntaxhighlighter" />来避免演示代码被执行和转义
<script type="syntaxhighlighter" class="brush: js"><![CDATA[ /** * SyntaxHighlighter */ function foo() { if (counter <= 10) return; // it works! } ]]></script>