这样试了不对:background-color:red 如何设置input 的背景颜色?其中type为text

解决方案 »

  1.   


    <style>
    input.text{background-color:red}
    </style>
    <input type="text" class="text">
    <input type="text" style="background-color:blue">
      

  2.   

    <style> 
      input.text{background-color:red}   
    </style>
        
    <script>   
      function   mm()   
      {   
          var   a   =   document.getElementsByTagName("INPUT");   
          for(var   i=0;   i<a.length;   i++)   if(a[i].type=="text")  a[i].className="text";  
      }   
    </script>   
        
    <body onload="mm()">

    <input/>
    <input/></body>