I'm currently utilizing the JavaScript code snippet below to clear out the existing content within a div element in order to insert new elements. However, I've encountered an issue where once the div is cleared, its CSS styling is lost. I am attempting to either retain or update the styling:
JavaScript Function
function Changecon() {
var element = document.getElementById("myList");
while (element.firstChild) {
element.removeChild(element.firstChild);
}
document.getElementById("myList").style.lineHeight="577";
};
Unfortunately, the last line of code seems to be ineffective. Any suggestions on how to resolve this? Thank you in advance.