高手帮忙看看我写的这点代码为什么在Ie上面能弹出层,在火狐上就不可以弹出层了?
<style>
.lou{ z-index:auto; position:absolute; background-image:url(../images/g.png);text-align:center; width:175px; height:78px; background-repeat:no-repeat; }
.we{ border-bottom:1px solid #E1E1E1; margin-bottom:8px;}
.hei1{font-size:15px; font-family:"微软雅黑"; font-weight:bolder; }
</style>
<script type="text/javascript">
//弹层代码
$(function() {
var x;
var y;
var divStr = "";
var a = $("a")
// $("a").mouseover(function() {
$("a").hover(function() {
divStr = "";
$("#lou").remove();
if (event.pageX == null && event.clientX != null) {
var doc = document.documentElement, body = document.body;
x = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
y = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
y = y - 300;
x = x - 50
} //外侧if
//鼠标点击楼时传入楼的Id
var id = $(this).attr("id")
$("#hidBuilId").val(id);
$.ajax({
type: "post",
url: "homeHandler/XiaoquBuilding.ashx",
dataType: "json",
data: "CommId=<%=community.CommunityId %>," + $(this).attr("id"),
success: function(message) {
if (message != null) {
// alert(x+","+y)
$.each(message.Building, function(i, item) {
divStr = "<div class=\"lou\" id=\"lou\" style=\"margin-left:" + x + "px; margin-top:" + y + "px; \" >";
divStr += "<ul> <li class=\"we\"><span class=\"hei1\">" + item.Id + "号</span> 入住用户" + item.ruzhu + " 还剩" + item.shengyu + "</li>"
divStr += "<li style=\"text-align:right;\"><img id=\"ruzhu\" src=\"<%=ruzhuImgUrl %>\" /> <img id=\"yezhu\"src=\"<%=yezhuImgUrl %>\"/></li>"
divStr += "</ul></div>"
});
} //内层if
$("#box").before(divStr);
}, //success
error: function(message) {
//alert(message);
}
}); // ajax
}); //hover 外层括号
//移除弹出层
$("a").hover(function() {
divStr = "";
$("#lou").remove();
});
});
</script>
其实要是代码写的规范 JS是最好的 未必JQUERY就在所有的浏览器都支持