1

I'm trying to show a map when I click on an h1 element. So I wrote my code which should do the trick but nothing happens. So I went looking for my JS console in my browser and there weren't any errors so I'm kinda stuck right now. Anyone that can help me out?

my HTML:
<section class="WT1">
<h1>Wetenschap & Techniek - Ellermanstraat &#8595</h1>
<div id="mapid"></div>
</section>


my JS
var touchMe = document.getElementsByTagName('h1');

touchMe.onhover = function() {
touchMe.style.cursor = 'pointer';
}

touchMe.onclick = function() {
document.getElementById('mapid').style.display = "block";
};
Stef Verniers
  • 31
  • 1
  • 9

1 Answers1

3

getElementsByTagName returns an array of elements, select one item from it

var touchMe = document.getElementsByTagName('h1')[0]
AlexOwl
  • 869
  • 5
  • 11