现在的位置: 首页 > 综合 > 正文

javascript — 动态创建HTML元素并插入到dom tree中

2013年03月07日 ⁄ 综合 ⁄ 共 2512字 ⁄ 字号 评论关闭

如何使用最原始的js脚本代码来操作html元素,下面的脚本示例了如何通过js动态创建html元素,如何通过js脚本控制html元素的css属性.

用到,所以记录一下:

 

 

顺便附上,js脚本上css属性对照表:

 

 

CSS Property JavaScript Reference
background background
background-attachment backgroundAttachment
background-color backgroundColor
background-image backgroundImage
background-position backgroundPosition
background-repeat backgroundRepeat
border border
border-bottom borderBottom
border-bottom-color borderBottomColor
border-bottom-style borderBottomStyle
border-bottom-width borderBottomWidth
border-color borderColor
border-left borderLeft
border-left-color borderLeftColor
border-left-style borderLeftStyle
border-left-width borderLeftWidth
border-right borderRight
border-right-color borderRightColor
border-right-style borderRightStyle
border-right-width borderRightWidth
border-style borderStyle
border-top borderTop
border-top-color borderTopColor
border-top-style borderTopStyle
border-top-width borderTopWidth
border-width borderWidth
clear clear
clip clip
color color
cursor cursor
display display
filter filter
font font
font-family fontFamily
font-size fontSize
font-variant fontVariant
font-weight fontWeight
height height
left left
letter-spacing letterSpacing
line-height lineHeight
list-style listStyle
list-style-image listStyleImage
list-style-position listStylePosition
list-style-type listStyleType
margin margin
margin-bottom marginBottom
margin-left marginLeft
margin-right marginRight
margin-top marginTop
overflow overflow
padding padding
padding-bottom paddingBottom
padding-left paddingLeft
padding-right paddingRight
padding-top paddingTop
page-break-after pageBreakAfter
page-break-before pageBreakBefore
position position
float styleFloat
text-align textAlign
text-decoration textDecoration
text-decoration: blink textDecorationBlink
text-decoration: line-through textDecorationLineThrough
text-decoration: none textDecorationNone
text-decoration: overline textDecorationOverline
text-decoration: underline textDecorationUnderline
text-indent textIndent
text-transform textTransform
top top
vertical-align verticalAlign
visibility visibility
width width
z-index zIndex

 

参考:

https://developer.mozilla.org/en/appendChild

http://codepunk.hardwar.org.uk/css2js.htm

http://dhtmlkitchen.com/learn/js/setstyle/

http://www.comptechdoc.org/independent/web/cgi/javamanual/javastyle.html

http://codingforums.com/showthread.php?t=27998

http://msdn.microsoft.com/en-us/library/ms535934(VS.85).aspx

 

 

 

抱歉!评论已关闭.