<style>
.info tr td input{background-color:red;}
</stye>
加载时可以这样定义input的style
如果鼠标放在<input>上的效果是指伪类:hover,浏览器不支持就没办法了。

解决方案 »

  1.   

    <style>
    .info tr td input{background-color:red;}
    </stye>
    加载时可以这样定义input的style
    如果鼠标放在<input>上的效果是指伪类:hover,浏览器不支持就没办法了。xxx:hover好像只有IE7和FIREFOX支持呀,主要是获得所有class="info"的table里面的type="text"的input,这个我不知道如果用脚本实现。
      

  2.   

    <script>
    function chg(){
    var tbls = document.getElementsByTagName("TABLE");
    var infotbls = new Array();
    var txtList = new Array();
    for(var i=0;i<tbls.length;i++){
      if(tbls[i].className=="info") infotbls[infotbls.length]=tbls[i];
    }
    for(var i=0;i<infotbls.length;i++){
       var list = infotbls[i].getElementsByTagName("INPUT");
       for(var j=0;j<list.length;j++){
         if(list[j].type=="text") txtList[txtList.length] = list[j];
       }
    }for(var i=0;i<txtList.length;i++){txtList[i].className="xxxx";} 
    }
    window.onload=function(){chg()}
    </script>
      

  3.   

    谢谢楼上的代码,如果是想实现只是鼠标放在INPUT上时改变其样式,如何写?
    我把楼主的代码:
    for(var i=0;i<txtList.length;i++){txtList[i].className="xxxx";} 
    改成了:
    for(var i=0;i<txtList.length;i++)

      txtList[i].onmouseover=function() { txtList[i].className="xxxx";}

    效果还是出不来。
      

  4.   

    txtList[i].onmouseover = function(){event.srcElement.className="abc";}
      

  5.   

    <table class="info" onmouseover=a() onmouseout=b() >
    <tr>
    <td><input type="text" class="form_input" ... /></td>
    <td><input type="text" class="form_input" ... /></td>
    <td><input type="button" ...  /></td>
    </tr>
    </table>
    <script>
    function a()
    {
    var o=event.toElement;
    if(o.type=="text") o.style.backgroundColor='red';
    }
    function b()
    {
    var o=event.fromElement;
    if(o.type=="text") o.style.removeAttribute("backgroundColor");
    }
    </script>
      

  6.   

    谢谢 hookee() 的代码
    --------------------------------------------------------------------------- 
    txtList[i].onmouseover = function(){event.srcElement.className="abc";}
    ---------------------------------------------------------------------------
    这个在IE下面可以实现了,但在FIREFOX下面不起作用?
      

  7.   

    ff:
    txtList[i].onmouseover = function(ev){ev.target.className="abc";}
    整合下就可以了