用js给html设置style

  1 [html] view plaincopyprint?
  2 原贴地址:<a href="http://heichong.iteye.com/blog/860698">http://heichong.iteye.com/blog/860698</a>  
  3 [html] view plaincopyprint?
  4 关键字: 用js给html表单设置style   
  5 首先,把CSS和JS标签style属性对照表了解了:  
  6   
  7 CSS 和 JavaScript 标签 style 属性对照表:  
  8   
  9    
 10   
 11 盒子标签和属性对照   
 12 CSS语法(不区分大小写)       JavaScript语法(区分大小写)   
 13 border              border   
 14 border-bottom           borderBottom   
 15 border-bottom-color     borderBottomColor   
 16 border-bottom-style     borderBottomStyle   
 17 border-bottom-width     borderBottomWidth   
 18 border-color            borderColor   
 19 border-left         borderLeft   
 20 border-left-color       borderLeftColor   
 21 border-left-style       borderLeftStyle   
 22 border-left-width       borderLeftWidth   
 23 border-right            borderRight   
 24 border-right-color      borderRightColor   
 25 border-right-style      borderRightStyle   
 26 border-right-width      borderRightWidth   
 27 border-style            borderStyle   
 28 border-top          borderTop   
 29 border-top-color        borderTopColor   
 30 border-top-style        borderTopStyle   
 31 border-top-width        borderTopWidth   
 32 border-width            borderWidth   
 33 clear               clear   
 34 float               floatStyle   
 35 margin              margin   
 36 margin-bottom           marginBottom   
 37 margin-left         marginLeft   
 38 margin-right            marginRight   
 39 margin-top          marginTop   
 40 padding             padding   
 41 padding-bottom          paddingBottom   
 42 padding-left            paddingLeft   
 43 padding-right           paddingRight   
 44 padding-top         paddingTop   
 45   
 46 颜色和背景标签和属性对照       
 47 CSS 语法(不区分大小写)   JavaScript 语法(区分大小写)   
 48 background          background   
 49 background-attachment       backgroundAttachment   
 50 background-color        backgroundColor   
 51 background-image        backgroundImage   
 52 background-position     backgroundPosition   
 53 background-repeat       backgroundRepeat   
 54 color               color   
 55     
 56 样式标签和属性对照   
 57 CSS语法(不区分大小写)       JavaScript 语法(区分大小写)   
 58 display             display   
 59 list-style-type         listStyleType   
 60 list-style-image        listStyleImage   
 61 list-style-position     listStylePosition   
 62 list-style          listStyle   
 63 white-space         whiteSpace   
 64     
 65 文字样式标签和属性对照   
 66 CSS 语法(不区分大小写)   JavaScript 语法(区分大小写)   
 67 font                font   
 68 font-family         fontFamily   
 69 font-size           fontSize   
 70 font-style          fontStyle   
 71 font-variant            fontVariant   
 72 font-weight         fontWeight   
 73     
 74 文本标签和属性对照   
 75 CSS 语法(不区分大小写)   JavaScript 语法(区分大小写)   
 76 letter-spacing          letterSpacing   
 77 line-break          lineBreak   
 78 line-height         lineHeight   
 79 text-align          textAlign   
 80 text-decoration         textDecoration   
 81 text-indent         textIndent   
 82 text-justify            textJustify   
 83 text-transform          textTransform   
 84 vertical-align          verticalAlign   
 85    
 86   
 87   
 88 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">  
 89 <HTML>  
 90  <HEAD>  
 91   <TITLE> New Document </TITLE>  
 92  </HEAD>  
 93 <script language="javascript">  
 94 function validate(){  
 95       if (document.all("name").value == ""){  
 96             document.all("name").style["borderColor"]="red";//就是这里  
 97             return;  
 98         }  
 99 }  
100 </script>  
101  <BODY>  
102   <input type="text" name="name" >  
103  </BODY>  
104 </HTML>  

 

posted @ 2014-02-27 17:11  天马3798  阅读(2890)  评论(0编辑  收藏  举报