Count a variable inside of innerHTML - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:html

Description

Count a variable inside of innerHTML

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"></script> 
      <script type="text/javascript">
    window.onload=function(){/*from  w  w w .  ja v  a 2s . c o  m*/

var counter = 1;
counter++;
console.log(counter);
$(".end").html('Test ' +( counter + 1 )+ ' Test');

    }

      </script> 
   </head> 
   <body> 
      <p class="end"></p>  
   </body>
</html>

Related Tutorials