如何用js给html表单设置style
关键字: 用js给html表单设置style 首先,把CSS和JS标签style属性对照表了解了:CSS 和 JavaScript 标签 style 属性对照表: 盒子标签和属性对照 CSS语法(不区分大小写)JavaScript语法(区分大小写) borderborder border-bottomborderBottom border-bottom-colorborderBottomColor border-bottom-styleborderBottomStyle border-bottom-widthborderBottomWidth border-colorborderColor border-leftborderLeft border-left-colorborderLeftColor border-left-styleborderLeftStyle border-left-widthborderLeftWidth border-rightborderRight border-right-colorborderRightColor border-right-styleborderRightStyle border-right-widthborderRightWidth border-styleborderStyle border-topborderTop border-top-colorborderTopColor border-top-styleborderTopStyle border-top-widthborderTopWidth border-widthborderWidth clearclear floatfloatStyle marginmargin margin-bottommarginBottom margin-leftmarginLeft margin-rightmarginRight margin-topmarginTop paddingpadding padding-bottompaddingBottom padding-leftpaddingLeft padding-rightpaddingRight padding-toppaddingTop 颜色和背景标签和属性对照 CSS 语法(不区分大小写) JavaScript 语法(区分大小写) backgroundbackground background-attachmentbackgroundAttachment background-colorbackgroundColor background-imagebackgroundImage background-positionbackgroundPosition background-repeatbackgroundRepeat colorcolor 样式标签和属性对照 CSS语法(不区分大小写)JavaScript 语法(区分大小写) displaydisplay list-style-typelistStyleType list-style-imagelistStyleImage list-style-positionlistStylePosition list-stylelistStyle white-spacewhiteSpace 文字样式标签和属性对照 CSS 语法(不区分大小写) JavaScript 语法(区分大小写) fontfont font-familyfontFamily font-sizefontSize font-stylefontStyle font-variantfontVariant font-weightfontWeight 文本标签和属性对照 CSS 语法(不区分大小写) JavaScript 语法(区分大小写) letter-spacingletterSpacing line-breaklineBreak line-heightlineHeight text-aligntextAlign text-decorationtextDecoration text-indenttextIndent text-justifytextJustify text-transformtextTransform vertical-alignverticalAlign
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML> <HEAD> <TITLE> New Document </TITLE> </HEAD><script language="javascript">function validate(){ if (document.all("name").value == ""){document.all("name").style["borderColor"]="red";//就是这里return;}}</script> <BODY> <input type="text" name="name" > </BODY></HTML>