Monday, 8 March 2021

HTML DOM activeElement Property

 <!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>

No comments:

Post a Comment

zomok E-commerce system plan. Choose your online ordering system. No-risk 30 day free trial. Then USD 9/month. No credit card required.

zomok E-commerce system plan. Choose your online ordering system. No-risk 30 day free trial. Then USD 9/month. No credit card required. h...