<html>
<head>
<title></title>
<script src="jquery_1.4.2.js"></script>
</head>
<body>
<div id="mapbox" style="float:left;position:relative;overflow:hidden;width:1200px;z-index:1;">
<img id="pic" width="1200px" height="1973px" style="position:relative;z-index:-1;" src="images/all.png" />
</div>
<script>
$(function(){
var being=true;
var lx=645;
var ly=-870;
var title0= "西城区";
var text0 = "时间: 2012-03-24 19:20:13<br>设备名称: 0016EC12428";
//alert("lx-->>"+lx);
//$("#mapbox").append("<div style='position:relative;top:"+ly+";left:"+lx+";'>。</div>");
$("#mapbox").append("<div style='position:relative;top:"+(ly-10)+";left:"+(lx-13)+";'><img id='img0' src='images/.png' /></div>");//在图片显示用户输入的信息
$("#img0").mouseover(function(){
if(being == false) return;
being = true;
//添加提示框
$("#mapbox").append("<div id='img00' style='border:solid 1px;"+
"width=300;height:150;padding:10px;margin:0; position:relative;z-index:-1;"+
"top:"+(ly-131)+";left:"+(lx-23+0)+";'>"+title0+
"<button style='position:relative;top:-2px;'"+
"name='close' value='关闭' id='3d00' onclick='being=true;$(\"#img00\").remove();' />"+
"<br>"+text0+"</div>");
});
/*
$("#img0").mouseout(function(){
if($("#img00"))
$("#img00").remove();
});
*/
$("#img0").click(function(){
alert("0 - turn to 3d map");
});
var lxs=423;
var lys=-1519; $("#mapbox").append("<div style='position:relative;top:"+(lys-10)+";left:"+(lxs-13)+";'><img id='img1' src='images/.png' /></div>");//在图片显示用户输入的信息
$("#img1").mouseover(function(){
if(being == false) return;
being = true;
//添加提示框
$("#mapbox").append("<div id='img00' style='border:solid 1px;"+
"width=300;height:150;padding:10px;margin:0; position:relative;z-index:-1;"+
"top:"+(lys-131)+";left:"+(lxs-23+0)+";'>"+title0+
"<button style='width:17px;height:17px;position:relative;top:-2px;'"+
"name='close' value='关闭' id='3d00' onclick='being=true;$(\"#img00\").remove();' />"+
"<br>"+text0+"</div>");
});
/*
$("#img1").mouseout(function(){
if($("#img11"))
$("#img11").remove();
});
*/
$("#img1").click(function(){
alert("1 - turn to 3d map");
});
});
</script>
</body></html>
试试
if (being == true) {
//添加提示框
$("#mapbox").append("<div id='img00' style='border:solid 1px;" +
"width=300;height:150;padding:10px;margin:0; position:relative;z-index:-1;" +
"top:" + (ly - 131) + ";left:" + (lx - 23 + 0) + ";'>" + title0 +
"<button style='position:relative;top:-2px;'" +
"name='close' value='关闭' id='3d00' onclick='being=true;$(\"#img00\").remove();' />" +
"<br>" + text0 + "</div>");
}
being = false;
});
这样应该就能满足你的要求。
先判断再添加
being=false;你的判断改为
if(being == true) return;//然后
being=true;
我试了下。。你这个事件没有触发啊
//添加提示框
$("#mapbox").append("<div id='img00' style='border:solid 1px;" +
"width=300;height:150;padding:10px;margin:0; position:relative;z-index:-1;" +
"top:" + (ly - 131) + ";left:" + (lx - 23 + 0) + ";'>" + title0 +
"<button style='width:17px;height:17px;position:relative;top:-2px;'" +
"name='close' value='关闭' id='3d00' />" +
"<br>" + text0 + "</div>");
}
being = false;
}); $('#3d00').live("click",function () {
alert('aa');
being=true;
$("#img00").remove();
});
这样应该就是你想要的结果