I just created and developed a jQuery plugin and it is working fine. But when I call more than one instance of it, some functions will affect on another instance. For example, I have list of items and a "Delete" button before each item. When you click on each "Delete" item, following function will fire:
$('.del-item').each(function(){
$(this).on('click',function(){
var $e = $(this).parent();
var val = $e.data('val');
$sourceBox.find('.source-item[data-val='+val+']').removeClass('selected-item added').find('span').remove();
$el.find('option[value='+val+']').removeAttr('selected').trigger('change');
$el.trigger('change');
$e.slideUp(200,function(){
$e.remove();
});
});
});
But it removes items from another list or affect on another instance of plugin. Please advice how can I access to only related items?
$el? (As opposed to$e?)