課程
/前端開發(fā)
/JavaScript
/表單驗證
為什么我寫的 pwd2.setAttribute("disabled");之后不能使用???
2015-02-03
源自:表單驗證 6-1
正在回答
setAttribute()這個函數(shù)需要兩個參數(shù),視頻里只給了一個,這樣寫就可以了:
pwd2.setAttribute("disabled","disabled");
paw2.setAttribute(disabled,"disabled");我這樣寫怎么也不行呢
我是沒看表單驗證這節(jié),不過下面的方法也能說明些問題。
setAttribute(class, value)中class是指改變class這個屬性,所以要帶引號。? vName代表對樣式賦值。? 例如:? var input = document.createElement(input);? input.setAttribute(type, text);? input.setAttribute(name, q);? input.setAttribute(class,bordercss);? 輸出時:,即,input控件具有bordercss樣式屬性注意:class屬性在W3C DOM中扮演著很重要的角色,但由于瀏覽器差異性仍然存在。使用setAttribute(class, vName)語句動態(tài)設(shè)置Element的class屬性在firefox中是行的通的,但在IE中卻不行。因為使用IE內(nèi)核的瀏覽器不認(rèn)識class,要改用className;同樣,firefox 也不認(rèn)識className。所以常用的方法是二者兼?zhèn)洌?/p>
element.setAttribute(class, value);? //for firefoxelement.setAttribute(className, value);? //for IE
舉報
表單驗證是JavaScript中的高級選項之一,輸入框的驗證
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2015-08-03
setAttribute()這個函數(shù)需要兩個參數(shù),視頻里只給了一個,這樣寫就可以了:
2015-06-13
paw2.setAttribute(disabled,"disabled");我這樣寫怎么也不行呢
2015-02-03
我是沒看表單驗證這節(jié),不過下面的方法也能說明些問題。
setAttribute(class, value)中class是指改變class這個屬性,所以要帶引號。
? vName代表對樣式賦值。
? 例如:
? var input = document.createElement(input);
? input.setAttribute(type, text);
? input.setAttribute(name, q);
? input.setAttribute(class,bordercss);
? 輸出時:,即,input控件具有bordercss樣式屬性
注意:class屬性在W3C DOM中扮演著很重要的角色,但由于瀏覽器差異性仍然存在。
使用setAttribute(class, vName)語句動態(tài)設(shè)置Element的class屬性在firefox中是行的通的,但在IE中卻不行。因為使用IE內(nèi)核的瀏覽器不認(rèn)識class,要改用className;
同樣,firefox 也不認(rèn)識className。所以常用的方法是二者兼?zhèn)洌?/p>
element.setAttribute(class, value);? //for firefox
element.setAttribute(className, value);? //for IE