samedi 17 octobre 2020

No element with class "textarea" in the html file. then how is it declared in the js file before its creation?

There is no element with class "textarea" in the html file. then how is it declared in the js file before its creation? And how the if condition is working?

divElem.addEventListener('click', function(){

    let notxtarea = document.getElementsByClassName('textarea').length;
    if(notxtarea == 0){
    let html = elem.innerHTML; 
    divElem.innerHTML= `<textarea class="form-control textarea" id="textarea" rows="3">${html}</textarea>`;
}
let textarea=document.getElementById('textarea');
    textarea.addEventListener('blur', function(){
        elem.innerHTML = textarea.value;
        localStorage.setItem('text', elem.innerHTML);
    })

});

Aucun commentaire:

Enregistrer un commentaire