let rolbtn = document.querySelector('#roles');
rolbtn.addEventListener('change',roles);

function roles(){
	let id = $('option:selected', this).attr('data-id'),response =  $('.resp-roles');
	if ($(`.roles${id}`).length == 0 && this.value !=='') {
		response.append(`
				<span class="tag_custom roles${id}" id="codenv${id}"><i class="icon-pen2"></i> ${this.value}
					<a href="#" class="delete_item" data-group="family" data-id="${id}">
						<i class="icon-cross"></i>
					</a>
					<input type="hidden" name="roles[]" value="${this.value}">
				</span>`
		);
	}
}
$(document).on("click",".delete_item",function(e){
	$('.roles'+$(this).data('id')).remove();
	e.preventDefault();
});