14. Remove CSS class names

 241 total views,  1 views today

We use the element’s classList object to remove the CSS class name.

  // Remove CSS class
  Q.fn.removeClass = function (className) {
    return this.each(function (e) {
      e.classList.remove(className);
    });
  }

Example => Step 14-> remove CSS class

Let’s do a quick test.

Q(() => {
  test("remove css class", function() {
    let $li = Q("#tasks>li:last-child");
    $li.removeClass("task");
    let $tasks = Q("li.task");
    assert($tasks.length == 5, ".task class added" );
  });
});