Pages

HTML5 classList API and Dartlang CssClassSet

Sunday, October 13, 2013
JavaScript's classList API is useful. It can manipulate css classes like jQuery's addClass, removeClass, toggleClass.
http://davidwalsh.name/classlist

For instance, you can write as follows (caution, IE version >= 10 required).

element.classList.add('foo');
element.classList.remove('foo');
element.classList.toggle('foo'); 

Dartlang has similar API named CssClassSet for that manipulation. Element object has classes property, and returns CssClassSet, which also provides add, remove, toggle, etc...

element.classes.add('foo');
element.classes.remove('foo');
element.classes.toggle('foo');

Thinking css class property, Set is proper name. Plus, since it implements Set, it provides more comprehensive functions than classList in JavaScript. http://api.dartlang.org/docs/bleeding_edge/dart_html/CssClassSet.html

2 comments:

  1. Hi friends, This is Rebeka from Chennai. I am a technology freak. I have read your blog. It was really a wonderful article and I was really impressed by reading this blog. Thanks for sharing this informative blog. I did HTML5 Training in Chennai at FITA academy, Its really useful for me to make a bright future.

    ReplyDelete
  2. Hallo friends, i'm from Indonesia. his info very interesting , I have a simple website Cara Agar Anak Tidak Gampang Sakit | Vitamin Anak Susah Makan | Cara Agar Anak Tidak Gampang Sakit and Suplemen Penambah Berat Badan Tanpa Efek Samping do not forget to visit our website friend ,
    thanks

    ReplyDelete