title: Adding HTML to page based on conditional logic in JavaScript or jQuery
body: <p>I have a <code>div</code> in which I have to fill some data in. I have to render the HTML based on conditions and I am adding data to that <code>div</code> using jQuery. Can someone please tell me how I can add the condition based insertion of HTML on the page?</p>
  
  <pre><code>      function AddData()
      {   
          var data = "&lt;div&gt;&lt;h1&gt;My data&lt;/h1&gt;"
               if(jsVariable){
                    &lt;p&gt;The JSVariable is present on page &lt;/p&gt;                
                          }
                 +"&lt;/div&gt;"
              $('.myDiv').after("&lt;br/&gt;"+data);
      }
  </code></pre>