元素ID在鼠标上方 [英] element id on mouse over
本文介绍了元素ID在鼠标上方的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用JavaScript来获取鼠标悬停的元素ID。但我没有得到它。
根据我的代码显示为空。
I'm using JavaScript to get the element's id on mouse over. But I am not getting it. As per my code it is showing null.
我的代码是:
My code is:
function getid() {
var e = document.getElementById(this);
alert(e);
}
我正在调用这个函数:
<input
style="margin: 8px 4px 4px 4px; width:142px; height:117px;"
type="image"
id="img"
src="images2.jpg"
onmouseover="getid();"
onmouseout="outmouse();"
/>
如何获取鼠标上的元素ID?
How can I get the elements id on mouse over?
解决方案
check this
函数getid(obj){
alert(obj.id);
}
< / script>
style =margin:8px 4px 4px; width:142px; height:117px;
type =image
id =img
src =images2.jpg
onmouseover =getid(this);
onmouseout =outmouse(this);
/>
这篇关于元素ID在鼠标上方的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文