<!doctype html>
<html>
<head>
<meta charset="gb2312">
<title>无标题文档</title>
<link href="css/style.css" rel="stylesheet" type="text/css">
<style>
.box{width:303px; height:628px; padding-top:66px; background:url(images/0T2154Z4-0_03.png) no-repeat center; }
#box-top{ width:285px; margin:0 auto 0; height:473px; font-size:16px; font-family:"仿宋"; color:#000; overflow:scroll}
#box-bottom{ width:285px; margin:0 auto; height:24px;}
#span{ display:inline-block; font-size:16px; color:#000; width:24px; height:100%;}
#text{ width:181px;border:1px solid #000;display:inline-block}
#button{ width:80px; height:100%; background:#000; border:1px solid #ccc ; color:#fff}\
img{ display:inline-block !important}
.p{ width:100%; height:auto; margin:3% auto}
.p>img{ display:inline-block; width:8%; max-width:8%}
.p>span{ display:inline-block; width:auto; max-width:90%; margin-left:2%}
.pa{ text-align:left}
.pa>span{ background:green}
.pb{ text-align:right}
.pb>span{ background:#0FF}
</style>
</head>
<body>
<div class="box">
<div id="box-top"></div>
<div id="box-bottom"><span id="span"><img id="img" src="images/inco.png" width="24"></span><input type="text" id='text' width="200" height="30"><input type="button" id="button" value="发送">
</div>
</div>
<script>
window.onload=function(){
var box=document.getElementById('box'),
boxTop=document.getElementById('box-top'),
boxbottom=document.getElementById('box-bottom'),
span=document.getElementById('span'),
imgs=document.createElement('img'),
img=document.getElementById('img')
text=document.getElementById('text'),
pa=document.getElementById('p')
flag=true,
button=document.getElementById('button');
img.onclick=function(){
if(flag){/*这个地方的判断等于flag=true*/
img.src='images/inco1.png';
flag=false
}else{
img.src='images/inco.png';
flag=true
}
}
button.onclick=function(){
if(text.value==''){
alert('发送的内容不能为空')
}else if(text.value=='js'){
alert('内容错误')
}else{
imgs.src=img.src;
if(flag){
boxTop.innerHTML+='<p id="p">'+imgs+'<span>'+text.value+'</span><p>'
}else{
boxTop.innerHTML+='<p id="p"><span>'+text.value+'</span>'+imgs+'<p>'
}
text.value=''
}
}
}
</script>
</body>
</html>
柠檬酸钠
相关分类