Skip to content

Instantly share code, notes, and snippets.

@carolina-vallejo
Last active January 4, 2018 11:18
Show Gist options
  • Save carolina-vallejo/7207de4173061643fb429fc57c3e000d to your computer and use it in GitHub Desktop.
Save carolina-vallejo/7207de4173061643fb429fc57c3e000d to your computer and use it in GitHub Desktop.
ui selector from list element in javascript
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