/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// attach onclick event listener to all .item(s) $$('#content .toggle_item').each(function(item) { item.addEvent('click', function(event) { var target = $(event.target); // check that target is as expected if(target.hasClass('toggle')) { this.toggleClass('active'); target.toggleClass('active'); target.hasClass('active') ? target.innerHTML = 'verstecken…' : target.innerHTML = 'mehr…'; } }) });