藍森林首頁 | 返回主頁 | 本站地圖 | 站內搜索 | 聯繫信箱 |
 您目前的位置:首頁 > 自由軟件 > 技術交流 > 應用編程


    

藍森林 http://www.lslnet.com 2006年8月25日 8:28

[Js]想把頁面上很多的輸入框和按鈕灰掉,有什麼簡單寫法嗎?

如題,按鈕和輸入框很多,不想一個一個寫。
請問有簡單的寫法嗎?
類似xxx.tagName=...,是循環的吧?

另外有幾個按鈕不想灰掉,怎麼把它們排除在外呢?謝謝。

[html]
<input type=button value=button>
<input type=submit value=submit>
<input type=reset value=reset>
<input type=checkbox value=button>checkbox
<input type=radio value=button>radio
<br>
<input type=button value=button noctl=true>
<input type=submit value=submit noctl=true>
<input type=reset value=reset noctl=true>
<input type=checkbox value=button noctl=true>checkbox
<input type=radio value=button noctl=true>radio
<script>
for(i=0;i<document.all.length;i++){
        if(document.all[i].tagName=="INPUT"){
                if(document.all[i].getAttribute("noctl")!="true"){
                        document.all[i].disabled=true;
                }
        }
}
</script>
[/html]
加了一個自定義屬性nocrl,如果是true則排除

哇,好厲害,佩服佩服,多謝多謝。學習學習中……




Copyright © 1999-2000 LSLNET.COM. All rights reserved. 藍森林網站 版權所有。 E-mail : webmaster@lslnet.com