I have a selectpicker list with initial style but when is populated the style is not applyed and I cannot change it using methods mentioned below
C#
Tip masura
Selecteaza tipul masurii
Masura de protectie
Selecteaza masuraand json for populating the select list
C#
$(function () {
$("#TipMasura").on("change", function () {
var categoryId = $("#TipMasura :selected").text();
$("#Masura").empty();
$("#Masura").append("--Selecteaza o masura existenta--");
$("#Masura").append("--Adauga o masura noua--");
$.getJSON(`?handler=Masura&id=${categoryId}`, (data) => {
$.each(data, function (i, item) {
$("#Masura").append(`${item.text}`);
});
$('#Masura').selectpicker({ liveSearch: true });
$("#Masura").selectpicker('refresh');
$("#Masura").addClass("sMasura")
});
var data = $("#TipMasura :selected").text();
$("#txtTM").val(data);
});
});
$(function () {
$("#Masura").on("change", function () {
var data = $("#Masura :selected").text();
if (data == "--Selecteaza o masura existenta--") {
$("#AddNew").attr("hidden", true);
$("#txtMasura").val("");
}
else if (data == "--Adauga o masura noua--") {
$("#AddNew").attr("hidden", false);
$("#txtMasura").val("");
}
else {
$("#AddNew").attr("hidden", true);
$("#txtMasura").val(data);
}
});
});and css
CSS
.sMasura{
font-size: 12px;
height: 50px;
color: darkred;
}I also tried $("#Masura").css("height", "50") but no results


Sachin SinghRank #66 · 26.2K reputationPosted Jan 8, 2023, 4:13 AM EST
No need to add class externally, the inline css should have worked.
can you please post the screenshot of inspected element from browser.
Right click on browser and inspect element and share the screenshot , i think the css would be present, there must be some parent contol's css causing the issue.
Marius VasileRank #785 · 2.9K reputationPosted Jan 8, 2023, 4:17 AM EST
yes it does. I've tried other ways and I came up with altering the css. Thank you Sachin