Javascript examples for DOM HTML Element:Heading
Add the userName to the h2 tag
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){//from ww w . j a v a 2 s . co m var h = document.querySelector('h2'); var userName "Please enter name"; h.innerHTML = h.innerHTML + ' / ' + userName } </script> </head> <body> <h2> H2 Text </h2> </body> </html>