1

I know how to get window location from the scroll function with javascript. But when I got the window location or px, How can I find the element tag name? Thanks

Husni Salax
  • 1,968
  • 1
  • 19
  • 29
Jamzaddy
  • 73
  • 6

1 Answers1

0

Here we go:

 <span id="myP">Click the button to display the tag name of this element.</span>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction() {
    var x = document.getElementById("myP").tagName;
    document.getElementById("demo").innerHTML = x;
}
</script>

You will get result: SPAN

Hope it helps;)

Husni Salax
  • 1,968
  • 1
  • 19
  • 29