<head> <script> function x(y) { const q = document.getElementById(y); alert(q.innerHTML); } </script> </head> <body> <button id="btn" onclick="x('thing')">Press </button> <div id="thing"> HELLO WORLD</div>