Posted By

wdso on 04/22/09


Tagged

event


Versions (?)


Advertising

Website Promotion DIRECTORY is a crucial factor for all websites that need to gain better organic search engine rankings and increase website traffic.
Submitting your website as part of your Web Promotion strategy to our SEO friendly and high traffic Business Directory for review is an excellent way to gain a valuable backlink and increase your websites visibility online.

Submit Site


Who likes this?

1 person has marked this snippet as a favorite

wdso


Smart on-click event handler for parent element


Published in: JavaScript 






Expand | Embed | Plain Text
  1. // attach onclick event listener to all .item(s)
  2. $$('#content .toggle_item').each(function(item) {
  3. item.addEvent('click', function(event) {
  4. var target = $(event.target);
  5. // check that target is as expected
  6. if(target.hasClass('toggle')) {
  7. this.toggleClass('active');
  8. target.toggleClass('active');
  9. target.hasClass('active') ? target.innerHTML = 'verstecken…' : target.innerHTML = 'mehr…';
  10. }
  11. })
  12. });

Report this snippet 

You need to login to post a comment.

Download royalty free graphics