Bonjour,
J'essaie cela :
function colorInvert(elem)
{ if(typeof elem==="string") elem=document.getElementById(elem);
let computedStyle=window.getComputedStyle(elem);
let backgroundColor=computedStyle.backgroundColor;
let textColor=computedStyle.color;
Code : Tout sélectionner
elem.style.backgroundColor = textColor;
elem.style.color = backgroundColor;
}
NB : les couleurs sont héritées de l'élément parent (txt noir, couleur blanc).
Je me retrouve systématiquement avec un tex noir sur fond noir et ce n'est pas très lisible.