I'm selecting multiple values in the dropdown list, based on selected values that need to display below with the checkbox is checked.
For Ex:
Multiple-Dropdown-list_image

below Output, I need to display like this when I selected multiple values:-

My Code:
$(document).ready(function() {
$(document).on('change','#tlist', function(){
$('#tdata').attr('style','display:block;');
var li = '';
$('#tlist').each(function() {
var values = $(this).val() ;
$.each(values, function( index, value ) {
var li = $('<input type="checkbox" class="custom-control-input" name="dfield[]" id="' + value + '" value="' + value + '" checked/><label class="custom-control-label blue" for="' + value + '">' + value + '</label>');
$('#tdata').append(li);
});
});
});
But here I'm getting output like this why? I have selected only 3 values so I need to display only 3 selected values. But it's showing some repeated values
OUTPUT:
