1

Temat: document.getElementById

<script>
  function test1()
  {
    var a = document.getElementById("a");
    a.innerHTML='<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Felis_catus-cat_on_snow.jpg/1200px-Felis_catus-cat_on_snow.jpg" width=300>';   
  }
  function test2()
  {
    var a = document.getElementById("a");
    a.innerHTML='<img src="https://www.colorland.pl/storage/app/uploads/public/a29/0MV/8xL/a290MV8xLmpwZyExY2E4OTk4Zjg1M2ZmNzYxODgyNDhhNmMyZjU1MjI5Ng==.jpg" width=300>';   
  }
  function test3()
  {
    var a = document.getElementById("a");
    a.innerHTML='Hello!';   
  }
</script>

<button onclick="test1()">test1</button>
<button onclick="test2()">test2</button>
<button onclick="test3()">test3</button>
<hr>
<p id="a"></p>

2

Odp: document.getElementById

<script>
  function test1()
  {
    var a = document.getElementById("a");
    var b = document.getElementById("b");
    var c = document.getElementById("c");
    //
    c.innerHTML=parseInt(a.innerHTML)+parseInt(b.innerHTML);
  }
</script>

<button onclick="test1()">test1</button>
<hr>
<p id="a">1</p> +
<p id="b">2</p> =
<p id="c">wynik</p>