87,918
社区成员
发帖
与我相关
我的任务
分享
<div class="mapwarp" id="mapwarp">
<img src="/images/map/test.jpg" />
</div>
$(document).ready(function () {
$(".mapwarp img").bind("click", function (e) {
//alert(e.pageX);//这是获取相对于窗口的位置,并不是层的,所以不行。
//alert(e.pageY);
GetPosition();
});
});
function GetPosition()
{
var x = $('.mapwarp').offset().left;
var y = $('.mapwarp').offset().top;
alert("x坐标:" + x);
alert("y坐标:" + y);
}
$(document).ready(function () {
$(".mapwarp img").bind("click", function (e) {
alert(e.offsetX);
alert(e.offsetY);
});
});