关于js获取id的坐标问题
今儿个写个下拉菜单效果,需要获取title的id,然后获取该id的坐标,给弹出菜单一个显示位置。
问题来了:在ie8和ff里面,可以获取到该id的坐标,而ie7、ie6获取的坐标都是0,0....
是命名可能重复?...改了好几个名字还是获取不到...
求解...
网页源代码:
<div class="top1" id="menu_img"> <a id="chanpin">策划案例</a> <a href="#" id="no">旅游婚纱</a> <a id="no" href="server.html">服务项目</a> <a id="no" href="aboutus.html">关于我们</a> <a id="no" href="index.html" style="margin:0 10px 0 20px;; background:none; width:190px; height:87px;"><img src="images/index_03.jpg"/></a> <a id="no" href="news.html">最新新闻</a> <a id="no" href="contact.html">联系我们</a> <a id="no" href="blong.html">博 客</a> <a id="no" href="weibo.html">微 博</a> </div>
$("#chanpin").mouseover(function(){ var menu_img=document.getElementById("chanpin"); var x=menu_img.offsetLeft; var y=menu_img.offsetTop; $("#sub_menu").css({"top": (y+35)+"px", "left": (x+0)+"px" }).show("fast"); $("#chanpin").css({"background":"#80064a", "color":"#fff" }); })