2011-10-03 87 views
0

我寫了一個帶有JSP的html文件。一個html標籤有一個onmouseover監聽器。當通過移動鼠標到標籤的innerhtml上調用mouseover方法時,如何獲得當前的html標籤對象?順便說一句,「這個」指針不指向標籤元素。如何獲取在JSP中調用onmouseover函數方法的html對象?

function dosth(){ 
    //TODO: get the object who calls this method. 
} 
.... 
<mytag onmouseover="dosth()">innerHTML</mytag> 

在上面的例子中,我怎樣才能得到mytag節點? mytag不允許有一個id。

+0

非常感謝。但我想知道,當鼠標移到innerHTML上時,實際調用onmouseover方法的人是窗口嗎? –

回答

1

<mytag onmouseover="dosth(this);">innerHTML</mytag>

發送到dosth的第一個參數將是調用它的元件。

+0

如果我已經在dosth()函數中有一些參數,例如dosth(p1,p2)。那麼你的意思是p1是調用dosth方法的對象嗎? –