JSLite - CSS class


If you have any questions, you are welcome to communicate in these places, and you are welcome to join the JSLite.io organization team for joint development!

css

Get or set the style content of the node object.

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

hasClass

Whether there is a node object in the collection containing the specified class.

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

addClass

Add the specified class name to each matching node object.

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

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

removeClass

Clear the specified class name of all node objects in the node object. If not filled in, clear it.

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

toggleClass

Adds or removes one or more style classes on each node object in the matching node object collection.

$("#box").toggleClass("box1 box2") //⇒ self 原有对象class上添加 "box1 box2"或者删除"box1 box2"