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
and json for populating the select list
$(function () {
$("#TipMasura").on("change", function () {
var categoryId = $("#TipMasura :selected").text();
$("#Masura").empty();
$("#Masura").append("");
$("#Masura").append("");
$.getJSON(`?handler=Masura&id=${categoryId}`, (data) => {
$.each(data, function (i, item) {
$("#Masura").append(``);
});
$('#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
I also tried $("#Masura").css("height", "50") but no results

Sachin SinghPosted Jan 8, 2023, 9:13 AM
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 VasilePosted Jan 8, 2023, 9:17 AM
yes it does. I've tried other ways and I came up with altering the css. Thank you Sachin