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