I would not change the css with js as that creates inline styles and ruins the specificity of the layout. Its ok for multiple progressions where you are progressively altering something but for one off changes simply add or remove classes as required and use css for what is was intended.
You would then use JS to add the appropriate class (i.e. playerStatus1 or 2 or 3 etc.) to .wrap as and when required (a question for Paul in the JS forum although you have enough snippets of JS now to accomplish this task yourself).
This keeps all styling information in the css and easy to change at a later date without touching the jS.
Those are a little verbose and you don’t really need the multiple dot separated classes except that as you already have them we have to follow suit.
The Js could be changed like this:
function changeBorderColor(playerStatus) {
let color;
if (playerStatus === 1) {
color = "playerStatus1";
}
if (color) {
document.querySelector(".wrapg").classList.add(color);
}
}
Of course @Paul_Wilkins may have something to say about that.
You have all the pieces to the jigsaw (I just gave them to you). Apply them in the right context and a little thought about what you are doing rather than blindly copying and pasting stuff.
This is what your latest would look like with the new code I suggested.
function changeBorderColor(playerStatus) {
const wrapper = document.querySelector(".wrapg");
let color;
if (playerStatus === 1) {
color = "playerStatus1";
}
if (color) {
wrapper.classList.add(color);
}
}
As I said in Chrome it just flickers off for a fraction of a second and seems to occur when you append your scripts so I don’t think there’s anything you can do about it (but I may be wrong).
Its a non-issue anyway and possibly an accessibility aid to tell you not to click yet as the thing hasn’t loaded.
You need to ask this in the JS forum as I don;t know what you are doing now. You seemed to be detecting an event change on the player and changing colours accordingly but now you just want to change it whatever?
You probably just need to add the class.
e.g.
function changeColor() {
wrapper.classList.add("playerStatus");
}
However I suggest you keep this in your other thread.