Created
November 7, 2011 16:47
-
-
Save MrMaksimize/1345481 to your computer and use it in GitHub Desktop.
Question - js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//why does this work? | |
if ($('a:has(span.menu-description)', menu).size() > 0) { | |
menu.addClass('admin-toolbar-menu-hover'); | |
$('a:has(span.menu-description)', menu).hover( | |
function() { | |
var link = $('<a></a>'); | |
$(link).attr('class', $(this).attr('class')); | |
$(link).addClass('menu-hover') | |
.append($('span.menu-description', this).clone()) | |
.appendTo(menu) | |
.show(); | |
}, | |
function() { | |
$(menu) | |
.children('a.menu-hover') | |
.remove(); | |
} | |
); | |
//but this says 'cant call method addClass of undefined'? | |
if ($('a:has(span.menu-description)', menu).size() > 0) { | |
menu.addClass('admin-toolbar-menu-hover'); | |
$('a:has(span.menu-description)', menu).hover( | |
function() { | |
$('<a></a>') | |
.attr('class', $(this).attr('class')) | |
.addClass('menu-hover') | |
.append($('span.menu-description', this).clone()) | |
.appendTo(menu) | |
.show(); | |
}, | |
function() { | |
$(menu) | |
.children('a.menu-hover') | |
.remove(); | |
} | |
); | |
//this also works using .prop | |
if ($('a:has(span.menu-description)', menu).size() > 0) { | |
menu.addClass('admin-toolbar-menu-hover'); | |
$('a:has(span.menu-description)', menu).hover( | |
function() { | |
$('<a></a>') | |
.attr('class', $(this).prop('class')) | |
.addClass('menu-hover') | |
.append($('span.menu-description', this).clone()) | |
.appendTo(menu) | |
.show(); | |
}, | |
function() { | |
$(menu) | |
.children('a.menu-hover') | |
.remove(); | |
} | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment