淡入淡出提示窗口 在添加成功之后提示一个窗口,添加成功,淡入淡出。出来提示一下然后消失?怎么实现?谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用div做提示窗口,动态改变它的 透明度 就能实现淡入淡出 用jquery<script>$("div").fadeOut("slow");$("div").fadeIn("slow");</script><div>添加操作成功</div> 如果是初学者,建议不要用Jquery去搞,自己写,主要用定时器与几个简单的样式 顶,推荐使用jquery,太方便了 恩,推荐jquery,初学者也一样,总得跟着新技术走吧 给个你看下<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title></title><style> *{ margin:0; padding:0; } body{ background-image:url(./test.jpg); } #layer{ position:absolute; top:0%; left:0%; filter:alpha(opacity=50); -moz-opacity:0.5; opacity: 0.5; background-color:#000; z-index:999; } #notice{ background-color: #F7F9EE; position:absolute; z-index:1999; width:230px; top:40%; left:40%; border: 1px solid #999933; overflow: hidden; } #notice h1{ color:#FF0000; height:20px; width:230px; padding-top:5px; padding-left:3px; font-size:14px; background-color:#006600; border-bottom:1px solid #999933; } #noticeContent{ padding:15px 20px; color:#666600; background-color: text-align:center; }</style><script type="text/javascript"> var Pop = { div0 : null,//遮罩层 div1 : null,//提示框 div2 : null,//指示内容 h1 : null,//指示标题 _$ : function(id){ return document.getElementById(id); }, _createLayer : function(){//创建遮罩层 this.div0 = document.createElement("div"); this.div0.setAttribute("id","layer"); if(parseInt(document.body.offsetHeight) > parseInt(document.documentElement.clientHeight)){ this.div0.style.height = parseInt(document.body.offsetHeight) + "px"; this.div0.style.height = parseInt(document.body.offsetWidth) + "px"; }else{ this.div0.style.height = parseInt(document.documentElement.clientHeight) + "px"; this.div0.style.width = parseInt(document.documentElement.clientWidth)+ "px"; } var parentNode = document.getElementsByTagName("body")[0]; parentNode.appendChild(this.div0); }, _createNotice : function(){//创建提示框 this.div1 = document.createElement("div"); this.div2 = document.createElement("div"); this.div1.setAttribute("id","notice"); this.div2.setAttribute("id","noticeContent"); this.h1 = document.createElement("h1"); this.h1.appendChild(document.createTextNode("操作指示")); }, showNotice : function(content,stime){//实现提示框功能 this._createLayer(); this._createNotice(); this.div2.appendChild(document.createTextNode(content)); this.div1.appendChild(this.h1); this.div1.appendChild(this.div2); document.body.appendChild(this.div1); var that = this; setTimeout(function(){ document.body.removeChild(that._$("layer")); document.body.removeChild(that._$("notice")); },stime); } }; </script></head><body>fdfdfddfddfsdfdsf<input type="button" value='show' onclick="Pop.showNotice('dont tach',1000)" /></body></html> 如果没有一定JS基础,一开始就用JQUERY,你会慢慢对JS失去兴趣! var isIe=(document.all)?true:false;/*** 方法:showBackground 淡入显示对象;hideBackground 淡出隐藏对象* 参数:obj 要控制的DIV对象;endInt 最终透明度(0至100)*/function showBackground(obj,endInt){ obj.style.display = "block"; if(isIe){ obj.filters.alpha.opacity+=10; if(obj.filters.alpha.opacity<endInt){ setTimeout(function(){showBackground(obj,endInt)},5); } }else{ var al=parseFloat(obj.style.opacity);al+=0.01; obj.style.opacity=al; if(al<(endInt/100)){ setTimeout(function(){showBackground(obj,endInt)},5); } } }function hideBackground(obj,endInt){ if(isIe){ obj.filters.alpha.opacity-=10; if(obj.filters.alpha.opacity>endInt){ setTimeout(function(){hideBackground(obj,endInt)},5); }else{ obj.style.display = "none"; } }else{ var al=parseFloat(obj.style.opacity);al-=0.01; obj.style.opacity=al; if(al>(endInt/100)){ setTimeout(function(){hideBackground(obj,endInt)},5); }else{ obj.style.display = "none"; } } }楼主可以参考 引用错误如果没有一定JS基础,一开始就用JQUERY,你会慢慢对JS失去兴趣! javascript里如何进行简单的图形处理? js如何判断网页是由ie打开的还是VC打开的 有几数组表单,js如何获得数组并动态相加输出到文本框 jsp中怎样重载上一个页面 $(target)什么意思 我改了后怎么就不支持鼠标事件了呢? 怎么判断一个文本框里的内容是否是数字? 如何控制按钮宽度? javascript的问题,急用 微信缓存怎么更新 javascript执行和页面同步 google Spreadsheets 源码分析
用jquery
<script>
$("div").fadeOut("slow");
$("div").fadeIn("slow");
</script>
<div>添加操作成功</div>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style>
*{
margin:0;
padding:0;
}
body{
background-image:url(./test.jpg);
}
#layer{
position:absolute;
top:0%;
left:0%;
filter:alpha(opacity=50);
-moz-opacity:0.5;
opacity: 0.5;
background-color:#000;
z-index:999;
}
#notice{
background-color: #F7F9EE;
position:absolute;
z-index:1999;
width:230px;
top:40%;
left:40%;
border: 1px solid #999933;
overflow: hidden;
}
#notice h1{
color:#FF0000;
height:20px;
width:230px;
padding-top:5px;
padding-left:3px;
font-size:14px;
background-color:#006600;
border-bottom:1px solid #999933;
}
#noticeContent{
padding:15px 20px;
color:#666600;
background-color:
text-align:center;
}
</style>
<script type="text/javascript">
var Pop = {
div0 : null,//遮罩层
div1 : null,//提示框
div2 : null,//指示内容
h1 : null,//指示标题
_$ : function(id){
return document.getElementById(id);
},
_createLayer : function(){//创建遮罩层
this.div0 = document.createElement("div");
this.div0.setAttribute("id","layer");
if(parseInt(document.body.offsetHeight) > parseInt(document.documentElement.clientHeight)){
this.div0.style.height = parseInt(document.body.offsetHeight) + "px";
this.div0.style.height = parseInt(document.body.offsetWidth) + "px";
}else{
this.div0.style.height = parseInt(document.documentElement.clientHeight) + "px";
this.div0.style.width = parseInt(document.documentElement.clientWidth)+ "px";
}
var parentNode = document.getElementsByTagName("body")[0];
parentNode.appendChild(this.div0);
},
_createNotice : function(){//创建提示框
this.div1 = document.createElement("div");
this.div2 = document.createElement("div");
this.div1.setAttribute("id","notice");
this.div2.setAttribute("id","noticeContent");
this.h1 = document.createElement("h1");
this.h1.appendChild(document.createTextNode("操作指示"));
},
showNotice : function(content,stime){//实现提示框功能
this._createLayer();
this._createNotice();
this.div2.appendChild(document.createTextNode(content));
this.div1.appendChild(this.h1);
this.div1.appendChild(this.div2);
document.body.appendChild(this.div1);
var that = this;
setTimeout(function(){
document.body.removeChild(that._$("layer"));
document.body.removeChild(that._$("notice"));
},stime);
}
};
</script>
</head>
<body>fdfdfddfddfsdfdsf
<input type="button" value='show' onclick="Pop.showNotice('dont tach',1000)" />
</body>
</html>
/**
* 方法:showBackground 淡入显示对象;hideBackground 淡出隐藏对象
* 参数:obj 要控制的DIV对象;endInt 最终透明度(0至100)
*/
function showBackground(obj,endInt){
obj.style.display = "block";
if(isIe){
obj.filters.alpha.opacity+=10;
if(obj.filters.alpha.opacity<endInt){
setTimeout(function(){showBackground(obj,endInt)},5);
}
}else{
var al=parseFloat(obj.style.opacity);al+=0.01;
obj.style.opacity=al;
if(al<(endInt/100)){
setTimeout(function(){showBackground(obj,endInt)},5);
}
}
}
function hideBackground(obj,endInt){
if(isIe){
obj.filters.alpha.opacity-=10;
if(obj.filters.alpha.opacity>endInt){
setTimeout(function(){hideBackground(obj,endInt)},5);
}else{
obj.style.display = "none";
}
}else{
var al=parseFloat(obj.style.opacity);al-=0.01;
obj.style.opacity=al;
if(al>(endInt/100)){
setTimeout(function(){hideBackground(obj,endInt)},5);
}else{
obj.style.display = "none";
}
}
}楼主可以参考
如果没有一定JS基础,一开始就用JQUERY,你会慢慢对JS失去兴趣!