Edit This Code:
<!DOCTYPE html>
<html>
<body onclick="myFunction()">

<p>Click anywhere in the document to display the active element.</p>
<input type="text" value="An input field">
<button>A Button</button>

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

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

</body>
</html>


Result:
Try it Yourself - © w3schools.com
Privacy Policy