Answer the question
In order to leave comments, you need to log in
Why is the data from the database not displayed?
The essence of the problem is that when loading the page, the data that I get from the database is not displayed when using this method:
let div = document.getElementById("keywords");
let arr = div.innerText.split(" ");
div.innerHTML = "";
for(let i = 0; i < arr.length; i++)
{
let span = document.createElement("span");
span.innerText = arr[i];
span.addEventListener("click", function() {
alert(this.innerText);
console.log(this.innerText);
});
div.appendChild(span);
div.appendChild(document.createTextNode(" "));
console.log("method_keywords");
}
<div id="keywords" class="col-md-9">
{{task.description}}
</div>
<div id="keywords" class="col-md-9">
something text text text text text
</div>
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