Jquery 设置控件位置的方法
//javascript写法 document.getElementById("child").style.left="800px"; document.getElementById("child").style.top="200px"; //jquery写法 //offset()获取当前元素基于浏览的位置 var offsettop=$("#unamespan").offset().top; var offsetleft=$("#unamespan").offset().left; //position()获取当前元素基于父容器的位置 var positiontop=$("#unamespan").position().top; var positionleft=$("#unamespan").position().left; //设置panel2的位置基于unamespan的坐标 $("#panel2").css({position: "absolute",'top':offsettop+100,'left':offsetleft+50,'z-index':2});