和css有关的方法有这些:
2016-06-13 10:16
666 查看
1、增 $(this).addClass("class1") 删 .removeClass("class2")
2、$(this).attr("className","class1") //attr两个功能之一 赋值 如下实例:
$(cs).attr("classqweasd", "xuanzhong BorderTrb hand ");这里的classqweasd
是所选元素的一个属性 可以是类名
2 取值
3、$(this).toggleClass("class1")如果原来没有class1就添加class1,如果原来有class1就移除class1
4、 $("#change_me").css("color":"yellow")
$("#change_me").css(
{"color":"yellow","left":"0"})
$("#change_me").toggle( 2000);//如果被选元素可见,则隐藏这些元素,如果被选元素隐藏,则显示这些元素。
$("#change_me").animate({ "top": "400", "font": "50px arial", "color": "red" }, 2000, "linear");// top400指距离上边距的位置
color不起作用 2000是过渡时长2秒
补充: this.style.cssText = "background-color:green;color:yellow;font-size:19px;
$("li").find("ul").css('background-color','blue');
2、$(this).attr("className","class1") //attr两个功能之一 赋值 如下实例:
$(cs).attr("classqweasd", "xuanzhong BorderTrb hand ");这里的classqweasd
是所选元素的一个属性 可以是类名
2 取值
3、$(this).toggleClass("class1")如果原来没有class1就添加class1,如果原来有class1就移除class1
4、 $("#change_me").css("color":"yellow")
$("#change_me").css(
{"color":"yellow","left":"0"})
$("#change_me").toggle( 2000);//如果被选元素可见,则隐藏这些元素,如果被选元素隐藏,则显示这些元素。
$("#change_me").animate({ "top": "400", "font": "50px arial", "color": "red" }, 2000, "linear");// top400指距离上边距的位置
color不起作用 2000是过渡时长2秒
补充: this.style.cssText = "background-color:green;color:yellow;font-size:19px;
$("li").find("ul").css('background-color','blue');
相关文章推荐
- CSS备忘录
- IE11下不能引入外部css的解决方法
- IE css hack
- 标准化命名CSS类,持续更新
- 梳理css-运行原理
- 使用important规则微调样式的顺序
- 文本超出编辑区域用省略号替代的css写法
- css3 背景渐变
- CSS实现三角形图标的原理
- css结合伪元素before,after制作网页返回顶部的图标
- css字体
- CSS中在body中添加overflow:hidden会发生什么
- css布局
- CSS 属性 - 伪类和伪元素的区别
- CSS文字样式
- DIV与CSS的结合使用
- MVC4.0 部署后css.js 失效
- 精通 CSS 选择器(二)
- safari中overflow:hidden对CSS模糊滤镜溢出隐藏无效解决办法
- css3写导入跳动的音乐