[url]http://zfms.iteye.com/blog/190948[/url]
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>
Height and Width, 高和宽:
height( ) Returns: Integer
能够返回对象的高度,jquery1.2还能支持返回document和window的高度。
例如:
height( val ) Returns: jQuery
设置对象的高度
width( ) Returns: Integer
返回对象的宽度, jquery1.2支持document和window的宽度
width( val ) Returns: jQuery
设置对象的宽度
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>
Height and Width, 高和宽:
height( ) Returns: Integer
能够返回对象的高度,jquery1.2还能支持返回document和window的高度。
例如:
function showHeight(ele, h) {
$("div").text("The height for the " + ele +
" is " + h + "px.");
}
$("#getp").click(function () {
showHeight("paragraph", $("p").height());
});
$("#getd").click(function () {
showHeight("document", $(document).height());
});
$("#getw").click(function () {
showHeight("window", $(window).height());
});
height( val ) Returns: jQuery
设置对象的高度
width( ) Returns: Integer
返回对象的宽度, jquery1.2支持document和window的宽度
width( val ) Returns: jQuery
设置对象的宽度