Last active
January 4, 2018 11:18
-
-
Save carolina-vallejo/7207de4173061643fb429fc57c3e000d to your computer and use it in GitHub Desktop.
ui selector from list element in javascript
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
function uiSelector($ulParent, $loader, $container) { | |
var $activeItem = $ulParent.find('li:first-child'); | |
if ($('#label-selector').length === 0) { | |
$ulParent.before('<div id="label-selector">' + $activeItem.text() + '</div>'); | |
$('#label-selector').on('click', function() { | |
$ulParent.slideToggle(); | |
$(this).toggleClass('toggle'); | |
}); | |
} | |
$ulParent.find('a').on('click.submenu-noticias', function() { | |
console.log('onclick a') | |
$('#label-selector').text($(this).parent('li').text()); | |
$ulParent.slideUp(); | |
$('#label-selector').removeClass('toggle'); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment