jquery 弹出div ajax请求返回data(html)当获得点击事件时把data apend到指定div中然后弹出div使背景变灰 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 简单写了下:<body> <div id="div1" style="width:2000px;height:2000px"> <div> <div></div> </div> <input type="button" id="btn1" value="层出来" /> </div></body><script type="text/javascript" src="jquery-1.3.2-min.js"></script><script type="text/javascript">$(document).ready(function() { var de=document.compatMode=="CSS1Compat"?document.documentElement:document.body; $("#btn1").click(function() { if($("#layer1").size()>0) { $("#layer1").css("display","block"); } else { var div=document.createElement("div"); div.id="layer1"; div.style.cssText="position:absolute;z-index:999;top:0;left:0;opacity:0.5;filter:alpha(opacity=50);background:#999999"; div.style.width=Math.max(de.offsetWidth,de.scrollWidth)+"px"; div.style.height=Math.max(de.offsetHeight,de.scrollHeight)+"px";document.title=de.offsetHeight+"|"+de.scrollHeight; var layer=document.createElement("div"); layer.style.cssText="position:fixed;_position:absolute;z-index:1000;width:400px;height:280px;background:#FFFFFF;border:solid 1px #09c;"; layer.innerHTML="<p>弹出层<p><span style='float:right;cursor:pointer;margin:5px 7px;'>关闭</span><input type='text'/>"; div.appendChild(layer); document.body.appendChild(div); layer.style.left=(de.clientWidth-layer.clientWidth)/2 +'px'; layer.style.top=(de.clientHeight-layer.clientHeight)/2 +'px' $("span",layer).click(function() { $("#layer1").css("display","none"); }); } });});</script> $.ajax({ url:'test.html', type: "GET", dataType: "html", success: function (data){ //怎么把data通过类似1楼的方法处理添加到弹出来的层里,大小是自动的 }}); $.ajax({ url:'test.html', type: "GET", dataType: "html", success: function (data){ if($("#layer1").size()>0) { $("#layer1").css("display","block"); } else { var div=document.createElement("div"); div.id="layer1"; div.style.cssText="position:absolute;z-index:999;top:0;left:0;opacity:0.5;filter:alpha(opacity=50);background:#999999"; div.style.width=Math.max(de.offsetWidth,de.scrollWidth)+"px"; div.style.height=Math.max(de.offsetHeight,de.scrollHeight)+"px";document.title=de.offsetHeight+"|"+de.scrollHeight; var layer=document.createElement("div"); layer.style.cssText="position:fixed;_position:absolute;z-index:1000;width:400px;height:280px;background:#FFFFFF;border:solid 1px #09c;"; $(layer).html(data); div.appendChild(layer); document.body.appendChild(div); layer.style.left=(de.clientWidth-layer.clientWidth)/2 +'px'; layer.style.top=(de.clientHeight-layer.clientHeight)/2 +'px' $("span",layer).click(function() { $("#layer1").css("display","none"); }); } } }); 使用EXT中的TabPanel无法填充整个画面~~求解~~ 2个obj值一样,为什么不能判断相等? 怎么比较两个字符型数字的大小 页面提交客户端验证和服务端验证 计算器的小疑问 怎么样在网站中添加1个浮动窗口? 问个菜菜的,快进来看看 请问怎么用代码取文本框中的内容啊? 怎样动态改变光标的状态??? 大虾帮忙,关于eval的问题,解决立即给分!!! 不能包含汉字和英文字母的正则 各位看下这段jquery哪出错
<div id="div1" style="width:2000px;height:2000px">
<div>
<div></div>
</div>
<input type="button" id="btn1" value="层出来" />
</div>
</body>
<script type="text/javascript" src="jquery-1.3.2-min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var de=document.compatMode=="CSS1Compat"?document.documentElement:document.body;
$("#btn1").click(function() {
if($("#layer1").size()>0) {
$("#layer1").css("display","block");
} else {
var div=document.createElement("div");
div.id="layer1";
div.style.cssText="position:absolute;z-index:999;top:0;left:0;opacity:0.5;filter:alpha(opacity=50);background:#999999";
div.style.width=Math.max(de.offsetWidth,de.scrollWidth)+"px";
div.style.height=Math.max(de.offsetHeight,de.scrollHeight)+"px";document.title=de.offsetHeight+"|"+de.scrollHeight;
var layer=document.createElement("div");
layer.style.cssText="position:fixed;_position:absolute;z-index:1000;width:400px;height:280px;background:#FFFFFF;border:solid 1px #09c;";
layer.innerHTML="<p>弹出层<p><span style='float:right;cursor:pointer;margin:5px 7px;'>关闭</span><input type='text'/>";
div.appendChild(layer);
document.body.appendChild(div);
layer.style.left=(de.clientWidth-layer.clientWidth)/2 +'px';
layer.style.top=(de.clientHeight-layer.clientHeight)/2 +'px'
$("span",layer).click(function() {
$("#layer1").css("display","none");
});
}
});
});
</script>
url:'test.html',
type: "GET",
dataType: "html",
success: function (data){
//怎么把data通过类似1楼的方法处理添加到弹出来的层里,大小是自动的
}
});
url:'test.html',
type: "GET",
dataType: "html",
success: function (data){
if($("#layer1").size()>0) {
$("#layer1").css("display","block");
} else {
var div=document.createElement("div");
div.id="layer1";
div.style.cssText="position:absolute;z-index:999;top:0;left:0;opacity:0.5;filter:alpha(opacity=50);background:#999999";
div.style.width=Math.max(de.offsetWidth,de.scrollWidth)+"px";
div.style.height=Math.max(de.offsetHeight,de.scrollHeight)+"px";document.title=de.offsetHeight+"|"+de.scrollHeight;
var layer=document.createElement("div");
layer.style.cssText="position:fixed;_position:absolute;z-index:1000;width:400px;height:280px;background:#FFFFFF;border:solid 1px #09c;";
$(layer).html(data);
div.appendChild(layer);
document.body.appendChild(div);
layer.style.left=(de.clientWidth-layer.clientWidth)/2 +'px';
layer.style.top=(de.clientHeight-layer.clientHeight)/2 +'px'
$("span",layer).click(function() {
$("#layer1").css("display","none");
});
}
}
});