jqurey实现点击按钮时让隐藏的div显示,并且背景发生变化,再点击时该div隐藏,背景变会原来
jqurey实现点击按钮时让隐藏的div显示,并且背景发生变化,再点击时该div隐藏,背景变会原来...
jqurey实现点击按钮时让隐藏的div显示,并且背景发生变化,再点击时该div隐藏,背景变会原来
展开
1个回答
展开全部
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>newPage</title>
</head>
<body>
<input id="newButton" type="button" value="点击" style="position: fixed;z-index:2" />
<script>
var newPage = {
bgColor1 : 'rgba(100,100,100,0.6)',
bgColor2 : 'rgba(170,200,120,0.9)',
fPage : document.createElement('div'),
qPage : document.createElement('div'),
count : 0,
click : function(){
if(++this.count%2 == 1){
this.fPage.style.backgroundColor=this.bgColor1;
this.fPage.style.position='absolute';
this.fPage.style.top='0px';
this.fPage.style.left='0px';
this.fPage.style.width='100%';
this.fPage.style.height='100%';
this.fPage.style.display='block';
this.qPage.style.backgroundColor=this.bgColor2;
this.qPage.style.position='absolute';
this.qPage.style.top='100px';
this.qPage.style.right='0px';
this.qPage.style.width='400px';
this.qPage.style.height='300px';
this.qPage.style.display='block';
document.body.appendChild(this.fPage);
document.body.appendChild(this.qPage);
}else{
this.fPage.style.display='none';
this.qPage.style.display='none';
}
}
}
document.getElementById('newButton').onclick=function(){newPage.click();}
</script>
</body>
</html>
我猜想楼主想要这个效果
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询