【发布时间】:2015-10-30 02:30:05
【问题描述】:
我有以下选择器:
$('#terminal-template').text()
以及正文中的以下jsp页面片段:
<script type="text/template" id="terminal-template">
<li data-terminal-id="{{ id }}" class="{{ clazz2 }}">
<label>
<input type="checkbox" name="terminal" class="{{ clazz }}" data-terminal-id="{{ id }}" />
<a href="#" title="" class="image"><img
src="getSmallThumbnail/{{imageId}}"
alt=""/></a>
<h3>{{ name }}
<small>{{ place }}</small>
</h3>
<p class="count">Проходимость: <span>{{ count }}</span> чел./час</p>
<p class="count">Стоимость: <span>{{ amount }}</span> руб./час</p>
<p class="count">Количество свободных слотов: <span>{{ numberOfEmptyCase }}</span> </p>
</label>
</li>
</script>
在 IE $('#terminal-template').text() 中返回空 ("")
但在 chrome 中 - 它可以正常工作并返回
"
<li data-terminal-id="{{ id }}" class="{{ clazz2 }}">
<label>
<input type="checkbox" name="terminal" class="{{ clazz }}" data-terminal-id="{{ id }}" />
<a href="#" title="" class="image"><img
src="getSmallThumbnail/{{imageId}}"
alt=""/></a>
<h3>{{ name }}
<small>{{ place }}</small>
</h3>
<p class="count">Проходимость: <span>{{ count }}</span> чел./час</p>
<p class="count">Стоимость: <span>{{ amount }}</span> руб./час</p>
<p class="count">Количество свободных слотов: <span>{{ numberOfEmptyCase }}</span> </p>
</label>
</li>
"
【问题讨论】:
-
您是否尝试过使用
.html()?.text()可能在 IE8 中使用script标记失败。 -
你用的是哪个版本的jquery?
-
jquery 1.8.2 版
-
好的。版本似乎还不错。我试过这个并且能够让它在 IE8
var templateVal = $('#terminal-template').clone(); console.log(templateVal.html());上运行你能试试这个并告诉我它是否适合你吗? -
Sushil,manji 已经答对了
标签: javascript jquery internet-explorer jquery-selectors