<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <script type="text/javascript"> function init() { console.log('init()'); document.getElementById('btnTeste02').focus(); var focusedElement = document.activeElement; console.log('Focused element: ' + focusedElement.innerHTML); focusedElement.click(); } </script> </head> <body> <button id="btnTeste01" onclick="console.log('Click: ' + this.innerHTML);">Teste 01</button> <button id="btnTeste02" onclick="console.log('Click: ' + this.innerHTML);">Teste 02</button> <button id="btnTeste03" onclick="console.log('Click: ' + this.innerHTML);">Teste 03</button> </body> </html> <script type="text/javascript"> init(); </script>
Thursday, December 27, 2012
Javascript / HTML - Find focused element
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment