Answer the question
In order to leave comments, you need to log in
How to fix Cannot read property 'insertAdjacentHTML' of null error?
Hello.
There is a program
function createModel(){
const models = document.getElementById("#parent");
let col_value = document.getElementById("color-result-nameID").textContent;
let col_text = document.getElementById("color-result-text_col").textContent;
let profit_ratio = document.getElementById("profit_ratio").value;
let manager_ratio = document.getElementById("manager_ratio").value;
let ad_ratio = document.getElementById("ad_ratio").value;
let n = document.getElementById("color-result-divn").textContent;
document.getElementById("color-result-divn").textContent = n+1;
// console.log("manager_ratio = ", manager_ratio);
const model = `
<div id = "child-${n+1}"; class="child">
<div class="child-1" style="background: ${col_value}">
<p class="collor-text" style="color: ${col_text}" >Цвет текста<span class="letter" onclick="closeDiv(this.closest('[id^=child]'))">×</span></p>
</div>
<p style="color: ${col_value}">Кф. прибыли
<p class="color-kf">${profit_ratio}</p></p>
<p style="color: ${col_value}">Кф.менеджера</p>
<p class="color-kf">${manager_ratio}</p></p>
<p style="color: ${col_value}">Кф. рекламы</p>
<p class="color-kf">${ad_ratio}</p></p>
</div>
`;
models.insertAdjacentHTML('afterbegin', model);
};
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question