i’m creating a chat for a website and when i display the mesages i want to change the color when the you are the owner.
i dont know how to make it, because the ul tags get stacked when you add more mesages
btw the style that i want to ass is: style=”background-color: #C9DAE4;”
this is the code
socket.on("postmesage", function (mesage, owner) {
var div = document.getElementById('chat');
div.innerHTML += `
<ul class="list-group list-group-horizontal" id="mesage">
<li class="list-group-item list-group-item-warning">${mesage.mesage}</li>
<li class="list-group-item list-group-item-warning" id="mesageowner">${mesage.owner}</li>
</ul>`;
if owner === document.getElementById("mesageowner").getAttribute('value')) {
alert("change style")
}
});
I have tried to get the mesage owner but it returns null.