【发布时间】:2013-03-20 21:50:31
【问题描述】:
我想根据用户输入显示一个属性名称并将其显示在 SyntaxHighlighter 中。 Another 帖子说这应该很容易。
JS
$('#inputText').keyup(function () {
var outputValue = $('#codeTemplate').html();//Take the output of codeTemplate
$('#codeContent').html(outputValue);//Stick the contents of code template into codeContent
var finalOutputValue = $('#codeContent').html();//Take the content of codeContent and insert it into the sample label
$('.popover #sample').html(finalOutputValue);
SyntaxHighlighter.highlight();
});
SyntaxHighlighter.all();
标记
<div style="display: none;">
<label class="propertyName"></label>
<label id="codeTemplate">
<label class="propertyName"></label>
//Not using Dynamic object and default Section (appSettings):
var actual = new Configuration().Get("Chained.Property.key");
//more code
</label>
<pre id="codeContent" class="brush: csharp;">
</pre>
</div>
<div id="popover-content" style="display: none">
<label id="sample">
</label>
</div>
这会输出纯文本。好像 SyntaxHighlighter 从未运行过。我怀疑这个问题与呈现页面后<pre> 不存在的事实有关。但是,更新
SyntaxHighlighter.config.tagName = "label";
与 pre to label 一起也不起作用。
【问题讨论】:
-
Get("<label id=".propertyName"></label>")?嵌套双引号?应该是Get("<label id='.propertyName'></label>")? -
@gongzhitaa- 这是一个很好的收获,但是更改引号并没有产生明显的影响。
-
将
Get("<label id=".propertyName"></label>")更改为Get('<label id=".propertyName"></label>')。这是有效的 jsfiddle:jsfiddle.net/2HuwB/1。我只是不知道 csharp 语法,即字符串是否可以单引号。
标签: javascript html syntaxhighlighter