Add the userName to the h2 tag - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Heading


Add the userName to the h2 tag

Demo Code

ResultView the demo in separate window

      <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

      <h2> H2 Text </h2>  

Related Tutorials