如果單擊顯示列表中的第一個值的按鈕,我試圖獲得警報。我使用下面的代碼基於這個threat。在這種威脅中,他們使用的不是一張表格。但我認爲那不是問題......我認爲現在是這樣。 I M使用的代碼是這樣的(其特點是從openlayer地圖):未被捕獲的參考錯誤:來自列表中的值的alertbox
<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>
I M在控制檯得到的錯誤是:未捕獲的ReferenceError:$沒有定義。 $是從這段代碼:
alert($("li.selected li:first").html());
有人能幫我一個忙嗎?
'$('...')'是jquery選擇器,是否在您的html頁面中包含了jquery? – Nadir
謝謝!我沒有意識到我使用它 – waywer