Implemented dynamic addition of <li> list items with nested <a><i></i></a> elements. The task is to remove the parent element <li> by clicking on the embedded <i> element, which in turn is nested in <a> .
Markup:
<div id="tabsSlide" class="tabs-slider"> <ul class="tabs-slider-wrapper nav nav-tabs js_order_service_tabs"> <li class="js_order_request_service_tab"> <a href="#order_service" data-toggle="tab"> <i class="icon icon-remove js_remove_service_tab"></i>Tab </a> </li> </ul> </div> Item delete code:
$('#removeTab').click(function(){ $(this).parent().remove(); }); Now when you click on the delete icon in the <i> , all dynamically created <li> elements are deleted. And you only need to remove the parent <li> element with all its contents.