【发布时间】:2016-03-08 20:57:37
【问题描述】:
如果单击显示列表中第一个值的按钮,我会尝试获取警报。我正在使用基于此threat 的以下代码。在这种威胁中,他们使用的是表格而不是列表。但我认为那不是问题……我认为是现在。我使用的代码是这样的。(这些特征来自一个开放层地图):
<ul id ="table_overvieuw">
<#list features as feature>
<li><b>Type: ${type.name}</b> (id: <em>${feature.fid}</em>):
<ul>
<#list feature.attributes as attribute>
<#if !attribute.isGeometry>
<li><b>${attribute.name}</b></li>
${attribute.value}
</#if>
</#list>
<br><br>
<input type="button" name="geef slijpplaten info" class="ok" value="OK" onclick="myFunction()" />
</ul>
</li>
</#list>
</ul>
<script type="text/javascript">
function highlight(e) {
if (selected[0]) selected[0].className = '';
e.target.parentNode.className = 'selected';
}
var table = document.getElementById('table_overvieuw'),
selected = table.getElementsByClassName('selected');
table.onclick = highlight;
function myFunction(){
alert($("li.selected li:first" ).html());
}
</script>
我在控制台中遇到的错误是:Uncaught ReferenceError: $ is not defined。 $ 来自这段代码:
alert($("li.selected li:first" ).html());
有人可以帮帮我吗?
【问题讨论】:
-
$('...')是 jquery 选择器,你的 html 页面中包含 jquery 吗? -
谢谢!我没有意识到我正在使用它
标签: javascript jquery html