css() jquery 改变dom属性方法, ()内放{}对象
如下代码:
<div id="text"></div>
<p>点击按钮换背景</p>
<button class="btn">换换换 </button>
样式()
#text{
width: 50rem;height: 20rem; background: url('images/b3.jpg') no-repeat;
}
js
$(document).ready(function(){
$(".btn").click(function(){
$("#text").css({"background":"url('images/3.jpeg') repeat"})
$("#text").css({"width":"40rem","height":"40rem"})
})
})
总结: css( )设置style里面的属性值
(ps : attr()获得或者设置元素的某个属性值 设置属性值时 属性值可以使函数值
obj.attr("title",function(){ return this.alt});
alert($("ul li:eq(1)").attr("title")); )