严生
严生
  • 发布:2015-06-06 14:57
  • 更新:2015-06-06 15:33
  • 阅读:7548

button 点击后怎么改变背景颜色

分类:HTML5+

.audit .you button{
box-sizing: border-box;
width:20%;
height:40px;
margin-left:5%;
float:left;
border-radius: 8px;
background-color: azure;
}
.audit .zuo button{
width:20%;
height:40px;
border-radius: 8px;
background-color: azure;
}

<div class="you"><button type="button" >同意</button></div>
<div class="zuo"><button type="button2" >不同意</button></div>

2015-06-06 14:57 负责人:无 分享
已邀请:
严生

严生 (作者)

<script>
function changeValue(){
one.value="nihao";
one.style.background="green";
}
function changeCss(){
var two =document.getElementById("two");
two.style.background="green";
}
</script>
<body>

    <button id="one" onclick="changeValue()">one</button><br>  
   <button id="two" onclick="changeCss()">two</button>  
</body>
严生

严生 (作者)

已经解决!!!
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>测试</title>
<link rel="stylesheet" type="text/css" href="css/xiao.css"/>
</head>
<style>
body{margin:0px;padding:0px;}

two,#one{width:100px;height:100px;background:red;position:absolute;top:20px;left:100px;}

one{top:20px;left:200px;}

</style>

<script>
function changeValue(){
one.value="nihao";
one.style.background="green";
}
function changeCss(){
var two =document.getElementById("two");
two.style.background="green";
}
</script>
<body>

    <button id="one" onclick="changeValue()">one</button><br>  
   <button id="two" onclick="changeCss()">two</button>  
</body>  

</html>

严生

严生 (作者)

<body>

    <button id="one" onclick="changeValue()">one</button><br>  
   <button id="two" onclick="changeCss()">two</button>  
</body>  

</html>

该问题目前已经被锁定, 无法添加新回复