<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
#box1{
width:200px;
height:350px;
border:1px solid #FC0;
}
#img1{
width:20px;
height:20px;
border:1px solid #000;
display:block;
float:left;
margin-top:2px;
}
</style>
</head>
<body>
<div id="box1"></div>
<img id="img1" />:
<input type="text" id="text1" /><input type="button" value="发送" id="btn1" />
<script>
var obox1=document.getElementById("box1");
var oimg1=document.getElementById("img1");
var otext1=document.getElementById("text1");
var obtn1=document.getElementById("btn1");
var onOff=true;
oimg1.onclick= function(){
if(onOff){
oimg1.src='img0/a.jpg';
onOff=false;
}
else{
oimg1.src='img0/b.jpg';
onOff=true;
}
}
btn1.onclick= function(){
if(onOff){
obox1.innerHTML+=oimg1.src+otext1.value;
}else{
obox1.innerHTML+=oimg1.src+otext1.value;
}
}
</script>
</body>
</html>
相关分类