0

How can I replace the innerHTML? Replace innerHTML on createElement, setAttribute throughout the application impossible.

Moderator

Hello World
  • 840
  • 10
  • 20
  • Sorry, what exactly are you trying to do? Are you trying to replace something with JavaScript? What application? What moderator? What addon are we talking about? – Amos M. Carpenter Jun 05 '14 at 07:10

1 Answers1

0
document.getElementById("information").innerHTML = info[0].getAttribute("text");

One line of code turns into tens ... Not very practical, but no other way.

var informationDiv1 = document.createElement('div');
var informationDiv2 = document.createElement('div');
var informationDiv3 = document.createElement('div');
var informationImg = document.createElement('img');

informationDiv1.setAttribute("class", "panel panel-primary");
informationDiv1.setAttribute("style", "margin: 20px;");
informationDiv2.setAttribute("class", "panel-body text-justify");
informationDiv2.textContent = info[0].getAttribute("text");
informationDiv3.setAttribute("class", "text-center");
informationImg.setAttribute("src", "/img/gif2.gif");
informationImg.setAttribute("style", "width: 235px; margin-bottom: 20px;");
informationImg.setAttribute("class", "img-thumbnail");

informationDiv1.appendChild(informationDiv2);
informationDiv3.appendChild(informationImg);
informationDiv1.appendChild(informationDiv3);

document.getElementById("information").appendChild(informationDiv1);
Hello World
  • 840
  • 10
  • 20