forEach

.forEach(fn)

fna function with 3 arguments : (element, index, the collection)

Iterate over the collection, executing a function for each matched element.

<div class="cl">1</div> <div class="cl">2</div> <span class="cl">3</span> <script> qs(".cl").forEach(function(elem, index, coll) { elem.attr("data-index", index); }); </script>

addClass

.addClass( className )

classNameOne or more space-separated classes to be added to the class attribute of each item of the collection.

Adds the specified class(es) of each item of the collection.

<div class="cl">1</div> <div class="cl">2</div> <span class="cl">3</span> <script> qs(".cl").addClass("red"); </script>

removeClass

.removeClass(className)

className : One or more space-separated classes to be removed from each item of the collection.

Remove a single class, multiple classes, or all classes from each item of the collection.

<div class="cl red">1</div> <div class="cl">2</div> <span class="cl red">3</span> <script> qs(".cl").removeClass("red"); </script>

toggleClass

.toggleClass(classNames)

classNames

Add or remove one or more classes from each element of the collection, depending on either the class’s presence or the value of the state argument.

<div class="cl red">1</div> <div class="cl">2</div> <span class="cl red">3</span> <script> qs(".cl").toggleClass("red"); </script>

setClass

.setClass(classNames)

classNames

Add or remove one or more classes from the element. Remove class if the className begins with '-' otherwise add

<div class="cl red">1</div> <div class="cl">2</div> <span class="cl red">3</span> <script> qs(".cl").setClass("-red green"); </script>

css

.css(jsonObject)

jsonObject

Return the css properties or set the css properties.

<div class="cl red">1</div> <div class="cl">2</div> <span class="cl red">3</span> <script> qs(".cl .red").css({ "background-color": "yellow", border: "dotted 1px green", margin: "10px" }); </script>

show

.show(visible)

visibleboolean indicate if show or hide

Display the element.

<div class="cl red">1</div> <div class="cl">2</div> <span class="cl red">3</span> <script> qs(".cl").show(true); </script>

remove

.remove()

Remove each element of the collection

<div class="cl red">1</div> <div class="cl">2</div> <span class="cl red">3</span> <script> qs(".cl").remove(); </script>