JS 改变input 输入框样式

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>Change.html</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
  <script language="javascript">
     function test4(event) {
	   if(event.value == "11") {
	      //??div1
	      //var div1 = document.getElementById(‘div1‘);
		  var div1 = document.getElementById("div1");
		  var div2 = document.getElementById("div2");
	      div1.style.backgroundColor="black";
		  div2.disabled = true;
		  div2.readOnly = true;
	   }
	   if(event.value == "22") {
	      //??div1
	      //var div1 = document.getElementById(‘div1‘);
		  var div1 = document.getElementById("div1");
		  var div2 = document.getElementById("div2");
	      div1.style.backgroundColor="red";
		   div2.disabled = false;
		   div2.readOnly = false;
	   }
	 }
  </script>
</head>
<body>
  <!--<div id="div1" style="width:400px; height:300px; background-color:red;">div1</div>-->
  <div id="div1" style="width:400px; height:300px; background-color:red;">div1</div>
  <input type="text" id="div2" value=""/>
  <input type="button" value="11" onclick="test4(this)"/>
  <input type="button" value="22" onclick="test4(this)"/>

  </body>
</html>

 不配图,复制代码一运行就能知道

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。