activeElement Property Example
RUN
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style type="text/css"> </style> </head> <body onclick="myFunction()"> <h1>Học lập trình miễn phí tại freetuts.net</h1> <p>Các bạn click vào bất cứ điểm nào trên trang để tìm phần tử đang được focus</p> <input type="text" value="Thẻ Input"> <button>Thẻ Button</button> <p id="result"></p> <script> function myFunction() { var x = document.activeElement.tagName; document.getElementById("result").innerHTML = "bạn đang focus vào thẻ " + x; } </script> </body> </html>
PHÓNG TO