 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML DOM activeElement Property
The HTML DOM activeElement property is a read-only property to return the currently focused element in the document.
Following is the syntax −
document.activeElement
Let us now see an example to implement the DOM activeElement property −
Example
<!DOCTYPE html> <html> <body onclick="display()"> <h2>Heading Two</h2> <p>Click in the element to get the active element.</p> <input type="text" value="Enter text..."> <p id="myid"></p> <script> function display() { var a = document.activeElement.tagName; document.getElementById("myid").innerHTML = a; } </script> </body> </html>  Output

Now, click the element to display the same currently active element −

Advertisements
 