здесь попробуйте это
$lastClass = 'fa-cubes';
$('.dropdown-item').click(function () {
$rootElement = $(this).parent().parent().parent().parent().find('.dropdown-toggle')[0];
$(this.classList).each(function (index, item) {
if (item.match('(^|\s)(fa\-[^\s]*)'))
{
console.log($rootElement);
if ($($rootElement).hasClass($lastClass)) {
$($rootElement).removeClass($lastClass);
}
$lastClass = item;
$($rootElement).addClass(item);
}
})
})