jQuery hover by paul irish


/ Published in: jQuery
Save to your folder(s)

this is coded by paul irish i just post it for future reference to me and my co-workers


Copy this code and paste it in your HTML
  1. // OMFG NO
  2. $('.unit').hover(function () {
  3. $(this).addClass('unit-hover');
  4. $(this).children('.thumb').children('a').children('.thumb_BW').addClass('hidden');
  5. $(this).children('.thumb').children('a').children('.thumb_C').removeClass('hidden');
  6. $(this).children('.arrow-details').removeClass('hidden');
  7. }, function () {
  8. $(this).removeClass('unit-hover');
  9. $(this).children('.thumb').children('a').children('.thumb_C').addClass('hidden');
  10. $(this).children('.thumb').children('a').children('.thumb_BW').removeClass('hidden');
  11. $(this).children('.arrow-details').addClass('hidden');
  12. });
  13.  
  14.  
  15.  
  16. // HELL YA
  17. $('.unit').hover(function (e) {
  18. var isIn = e.type === 'mouseenter',
  19. $this = $(this);
  20.  
  21. $this.toggleClass('unit-hover',isIn);
  22. $this.find('.thumb a')
  23. .children('.thumb_BW').toggleClass('hidden',isIn)
  24. .end()
  25. . children('.thumb_C').toggleClass('hidden',!isIn);
  26.  
  27. $this.children('.arrow-details').toggleClass('hidden',!isIn);
  28. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.