how to add css in innerText

hello I have a function in javascript that generates an error message
But I would like to add css in the error message
for example a yellow background and a red color

 let btn = document.getElementsByClassName("buttons"); 
 let D = document.getElementsByClassName("div_text");
 let errorMessage = document.createElement("div"); 
 stringLength = document.getElementById('username');
const regex = /\W/; = 'warning';
  stringLength.addEventListener('input', function (evt) {
    if (stringLength.value.length > 10) {
         document.getElementById('warning').innerText = "le nombre          de caractères maximum autorisés est de 10"
      btn[0].disabled = true;

>Solution :


Leave a Reply