<!-- [if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:PunctuationKerning/> <w:DrawingGridVerticalSpacing>7.8 磅</w:DrawingGridVerticalSpacing> <w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEvery> <w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridEvery> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:Compatibility> <w:SpaceForUL/> <w:BalanceSingleByteDoubleByteWidth/> <w:DoNotLeaveBackslashAlone/> <w:ULTrailSpace/> <w:DoNotExpandShiftReturn/> <w:AdjustLineHeightInTable/> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> <w:UseFELayout/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!-- [if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> </w:LatentStyles> </xml><![endif]--><!-- [if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:普通表格; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]-->
传统
javascript
对
css
的操作相当繁琐,比如
<div
id="a" style="background:blue">css</div>
取它的
background
语法是
document.getElementById("a").style.background
,而
jQuery
对
css
更方便的操作,
$("#a").background()
,
$("#a").background(“red”)
$("#a")
得到
jQuery
对象
[ <div id="a" … /div> ]
$("#a").background()
将取出该对象的
background
样式。
$("#a").background(“red”)
将该对象的
background
样式设为
redjQuery
提供了以下方法,来操作
css
background () background
(val) color()
color(val) css(name)
css(prop)
css(key,
value)float()
float(val) height() height(val) width()
width(val)
left()
left(val) overflow()
overflow(val) position() position(val)
top() top(val)
这里需要讲解一下 css(name) css(prop) css(key, value) ,其他的看名字都知道什么作用了!
< div id ="a" style ="background:blue;color:red"> css </ div >< P id ="b"> test </ P >
css(name)
获取样式名为
name
的样式
$("#a").css("color")
将得到样式中
color
值
red
,
("#a").css("background ")
将得到
blue
css(prop)
prop
是一个
hash
对象,用于设置大量的
css
样式
$("#b").css({ color: "red", background: "blue"
});
最终效果是
<p id="b" style="background:blue;
color:red">test</p>,{ color: "red", background:
"blue" }
,
hash
对象,
color
为
key
,
"red"
为
value
,
css(key, value)
用于设置一个单独得
css
样式
$("#b").css("color","red");
最终效果是
<p id="b"
style="color:red">test</p>
219

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



