qq_哦哦_10
2017-02-15 09:58
<script language="javascript">
/*var myarr = new Array(3);
myarr[0]=88;
myarr[1]=90;
myarr[2]=68;*/
myarr = [88,90,68];
function aa(){
if( document.getELementById("input").style.backgroundColor="red"){
document.getELementById("input").style.backgroundColor="blue"
}
else{
document.getELementById("input").style.backgroundColor="red"
}
}
document.write("数组第一个值是:"+myarr[1]+"<br>");
document.write("数组第二个值是:"+myarr[2]+"<br>");
document.write("数组第三个值是:"+myarr[0]+"<br>");
</script>
</head>
<body>
<input name="button" value="点击变色" onclick="aa()"/>
</body>
</html>
document.getELementById("input")
<input name="button" value="点击变色" onclick="aa()"/>根本没有设置ID名
亲,先把id弄清楚吧
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title> 卸载事件 </title>
<script language="javascript">
/*var myarr = new Array(3);
myarr[0]=88;
myarr[1]=90;
myarr[2]=68;*/
myarr = [88,90,68];
function aa(){
if( document.getElementById("ipt").style.backgroundColor=="red"){
document.getElementById("ipt").style.backgroundColor="blue"
}
else{
document.getElementById("ipt").style.backgroundColor="red"
}
}
document.write("数组第一个值是:"+myarr[1]+"<br>");
document.write("数组第二个值是:"+myarr[2]+"<br>");
document.write("数组第三个值是:"+myarr[0]+"<br>");
</script>
</head>
<body>
<input type="button" value="点击变色" onclick="aa()" id='ipt'/>
</body>
</html>
if判断用“==”,用“=”是赋值了
JavaScript进阶篇
468060 学习 · 21891 问题
相似问题