Return to Snippet

Revision: 13387
at April 22, 2009 06:44 by wdso


Initial Code
// 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…';
    }
  })
});

Initial URL


Initial Description


Initial Title
Smart on-click event handler for parent element

Initial Tags
event

Initial Language
JavaScript