- Javascript获取鼠标位置,显示Memo,相当于Alt和Title属性,但是要比Alt和Title拉风啊
- < html >
- < head >
- < script type = "text/javascript" >
- function showMemo(evt,data) {
- //alert(evt.clientX);
- document.getElementById.('memo').style.left = evt .clientX;
- document.getElementById.('memo').style.top = evt .clientY;
- document.getElementById.('memo').innerHTML = data ;
- document.getElementById.('memo').style.display = 'block' ;
- }
- function hideMemo() {
- document.getElementById.('memo').style.display = 'none' ;
- }
- </ script >
- </ head >
- < body >
- < table >
- < tr >
- < td onmouseover ="showMemo(event,'Memo1');" onmouseout ="hideMemo();" > aaa </ td >
- < td onmouseover ="showMemo(event,'大家好,我是Memo2!!!');" onmouseout ="hideMemo();" > aaa </ td >
- < td onmouseover ="showMemo(event,'大家好,我是Memo3!!!');" onmouseout ="hideMemo();" > aaa </ td >
- < td onmouseover ="showMemo(event,'大家好,我是Memo4!!!');" onmouseout ="hideMemo();" > aaa </ td >
- < td onmouseover ="showMemo(event,'大家好,我是Memo5!!!');" onmouseout ="hideMemo();" > aaa </ td >
- < td onmouseover ="showMemo(event,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');" onmouseout ="hideMemo();" > aaa </ td >
- </ tr >
- < tr >
- < td > bbb </ td >
- < td > bbb </ td >
- < td > bbb </ td >
- < td > bbb </ td >
- < td > bbb </ td >
- < td > bbb </ td >
- </ tr >
- < tr >
- < td > ccc </ td >
- < td > ccc </ td >
- < td > ccc </ td >
- < td > ccc </ td >
- < td > ccc </ td >
- < td > ccc </ td >
- </ tr >
- </ table >
- < div id = "memo" style = "position:absolute;border:1px solid blue;background:yellow;width:100px;display:none;word-wrap:break-word" > ddd </ div >
- </ body >
- </ html >
Javascript捕获鼠标位置(跨浏览器)
最新推荐文章于 2017-06-09 16:40:00 发布