codecamp

JSLite - CSS 类

如有疑问欢迎到这些地方交流,欢迎加入JSLite.io组织团伙共同开发!

segmentfault社区 | 官方网站 | 官方文档-更详细 | Issues

css

获取或设置节点对象的style样式内容。

$("#box").css("color","yellow")     //⇒ self 返回Array 节点内容
$("#box").css({"color":"yellow"})   //⇒ self 返回Array 节点内容

hasClass

集合中是否有节点对象含有指定的class。

$("#box").hasClass("box2") //⇒ true

addClass

为每个匹配的节点对象添加指定的class类名。

$("#box").addClass("box23 go") //⇒ self 原有对象class上添加 box23和 go


$("#box").addClass(function(){
    return "box23 wcj"
}) //⇒ self 原有对象class上添加 box23 和wcj

removeClass

清除节点对象中所有节点对象的指定class类名,不填写清空。

$("#box").removeClass("box23") //⇒ self 删除原有对象class中box23
$("div").removeClass() //⇒ self  所有匹配的对象class属性被删除

toggleClass

在匹配的节点对象集合中的每个节点对象上添加或删除一个或多个样式类。

$("#box").toggleClass("box1 box2") //⇒ self 原有对象class上添加 "box1 box2"或者删除"box1 box2"
JSLite - 节点属性
JSLite - 效果
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }