I have a div <div id="MetricsTypeYearModelList"></div>
. In this div i am dynamically adding a ul element
$("#MetricsTypeYearModelList").append('<ul class="modal__list mCustomScrollbar" id="MetricsTypeYearModelListUl"></ul>');
After this i am looping over a JSON object and adding li element dynamically to the ul element
for (var i = 0; i < metricsTypeYearModel.length; i++)
{
var obj = metricsTypeYearModel[i];
$("#MetricsTypeYearModelListUl").append('<li data-name='+obj.ModelTypeName+' data-value='+obj.ModelTypeID+' data-id='+obj.ModelTypeID+' class="pModel"><a href="#"> '+obj.ModelTypeName+'</a></li>');
}
I have used "mCustomScrollbar" class in my ul element but this does not show up, normal scroll bar does show up. How can i show the CustomScrollBar
` elements, you add attach an *id* to it. You then go on to make another append logic on the same `
– Martin Sep 27 '18 at 07:46` element going by *id* as your selector. Note that *id* is a *unique* selector. Therefore, your `$("#MetricsTypeYearModelListUl").append()` will only be applied to the first element it finds with the relevant *id*.