0
現在,我想創建一個函數,如果用戶將鼠標懸停在具有特定ID的標題鏈接上(在動態創建的鏈接上),它將顯示一個彈出框。現在,它似乎正在處理第一個鏈接,但它並不適用於其他鏈接。我認爲這是因爲它與動態創建的對象有關,但我不知道如何解決這個問題。如何在動態創建的對象上使用Javascript
下面是我在JDBC
代碼Test.java
out.println("<div id=\"container\">
+ <a href=\"getName?ID=" + result.getInt(1) + "\" onmouseover=\""
+ DisplayPopup + "\">"
+ result.getString(2) + "</a>" //dynamically retrieved name
out.println("<div id=\"descriptionbox\">"
+ "Name: " + result.getString(1) + "<br/>"
+ "Birthday: " + result.getString(2) + "<br/>"
);
DisplayPopup.js
function popup(path) {
var ajaxRequest;
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
var e = document.getElementById('container');
e.onmouseover = function() {
document.getElementById('descriptionbox').style.display = 'block';
}
e.onmouseout = function() {
document.getElementById('descriptionbox').style.display = 'none';
}
}
}
ajaxRequest.open("GET", path, true);
ajaxRequest.send(null);
}
「DisplayPopup」的內容是什麼? – brso05
其在HTML代碼中的div ID「descriptionbox」 – mary
不,我的意思是'+ DisplayPopup +「\」>「'... – brso05