function applyCss(){
var inputObjs = document.getElementsByTagName("input");
try{
for(x in inputObjs){
if(inputObjs[x].type == "text" || inputObjs[x].type == "password")
inputObjs[x].className = "inputtext";
if(inputObjs[x].type == "button" || inputObjs[x].type =="submit" ||
inputObjs[x].type == "reset")
inputObjs[x].className = "inputbutton" ;
}
}
catch(err){
alert(err.description);
}
}
var inputObjs = document.getElementsByTagName("input");
try{
for(x in inputObjs){
if(inputObjs[x].type == "text" || inputObjs[x].type == "password")
inputObjs[x].className = "inputtext";
if(inputObjs[x].type == "button" || inputObjs[x].type =="submit" ||
inputObjs[x].type == "reset")
inputObjs[x].className = "inputbutton" ;
}
}
catch(err){
alert(err.description);
}
}
本文介绍了一个JavaScript函数,该函数能够自动为网页上的输入元素(如文本框、按钮等)应用预定义的CSS类名,从而简化了网页样式的统一管理。
1513

被折叠的 条评论
为什么被折叠?



