• function

can.addClass

 

Add a class to elements.

can.addClass(nodeList, className)

Parameters

  1. nodeList {NodeList}

    The list of HTML elements to add the class to.

  2. className {String}

    The class to add.

can.addClass( nodelist, className ) adds the specified class(es) to nodelist's HTMLElements. It does NOT replace any existing class(es) already defined.

// Before
can.addClass(can.$("#foo"),"bar") // After

You can also pass multiple class(es) and it will add them to the existing set also.

// Before
can.addClass(can.$("#foo"),"bar man") // After

This works similarly to jQuery.fn.addClass.