After generating a new list item, it appears that the CSS styling is not being inherited until the page is reloaded. Even though I have added styling using cssText dynamically, it doesn't seem to be working as expected.
I've attempted using cssText and inline jQuery to apply the styles.
if (data.success) {
console.log("Data success");
// get the data that was returned.
const contents = `${data.chatroom}`
// create the dom tree under contacts
const li = document.createElement('li');
const div = document.createElement('div');
const span = document.createElement('span');
const div0= document.createElement('div')
const p = document.createElement('p');
const p0 = document.createElement('p');
li.classList.add('contact');
div.classList.add('wrap');
div0.classList.add('meta');
p.classList.add('name');
p0.classList.add('preview');
// setting innerHTML of new dom tree
p.innerHTML = contents;
div0.append(p);
span.append(div0);
div.append(span);
li.append(div);
var css = {"padding": "15px 0 30px 18px", "display": "block", "cursor": "pointer"};
li.style.cssText = css;
document.querySelector('#contacts').appendChild(li);
Despite my efforts, the newly generated list items are not reflecting the padding, display, and cursor styles dynamically as intended.