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
Asked
Active
Viewed 51 times
1
-
1yes, dublicate http://stackoverflow.com/questions/8813051/determine-which-element-the-mouse-pointer-is-on-top-of-in-javascript – Andrew Evt Apr 27 '16 at 07:41
-
@AndrewEvt Thanks a lot – Jamzaddy Apr 27 '16 at 07:45
1 Answers
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
-
Thanks but, i want to know element tag from the scroll location in browser. – Jamzaddy Apr 27 '16 at 08:07