/ Published in: JavaScript
Imagine an element that has two states, represented by two CSS classes named 'expanded' and 'contracted.' This code toggles between the two states in the simplest possible fashion.
Expand |
Embed | Plain Text
el.className = (el.className.indexOf('expanded') != -1) ? el.className.replace(/expanded/,'contracted') : el.className.replace(/contracted/,'expanded');
You need to login to post a comment.
