Guest User

Untitled

a guest
Aug 20th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. //why does this work?
  2. if ($('a:has(span.menu-description)', menu).size() > 0) {
  3. menu.addClass('admin-toolbar-menu-hover');
  4. $('a:has(span.menu-description)', menu).hover(
  5. function() {
  6. var link = $('<a></a>');
  7. $(link).attr('class', $(this).attr('class'));
  8. $(link).addClass('menu-hover')
  9. .append($('span.menu-description', this).clone())
  10. .appendTo(menu)
  11. .show();
  12. },
  13. function() {
  14. $(menu)
  15. .children('a.menu-hover')
  16. .remove();
  17. }
  18. );
  19. //but this says 'cant call method addClass of undefined'?
  20. if ($('a:has(span.menu-description)', menu).size() > 0) {
  21. menu.addClass('admin-toolbar-menu-hover');
  22. $('a:has(span.menu-description)', menu).hover(
  23. function() {
  24. $('<a></a>')
  25. .attr('class', $(this).attr('class'))
  26. .addClass('menu-hover')
  27. .append($('span.menu-description', this).clone())
  28. .appendTo(menu)
  29. .show();
  30. },
  31. function() {
  32. $(menu)
  33. .children('a.menu-hover')
  34. .remove();
  35. }
  36. );
  37.  
  38. //this also works using .prop
  39.  
  40. if ($('a:has(span.menu-description)', menu).size() > 0) {
  41. menu.addClass('admin-toolbar-menu-hover');
  42. $('a:has(span.menu-description)', menu).hover(
  43. function() {
  44. $('<a></a>')
  45. .attr('class', $(this).prop('class'))
  46. .addClass('menu-hover')
  47. .append($('span.menu-description', this).clone())
  48. .appendTo(menu)
  49. .show();
  50. },
  51. function() {
  52. $(menu)
  53. .children('a.menu-hover')
  54. .remove();
  55. }
  56. );
  57. }
Add Comment
Please, Sign In to add comment