sudhakarinfotech
(current)
Run Code
Live Code Editor- Javascript Fetch Id
Source Code
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Fetching HTML Element Through Id</title> <script> function displayResult() { document.getElementById("main_heading").innerHTML = "You can see the result right now."; } </script> </head> <body> <h1 id="main_heading">This is HTML heading tag</h2> <br /> <button type="button" onclick="displayResult(); "> Click To See The Result </button> </body> </html>
Source Code Output :
Running