title: How to write php if statement in jquery script
body: <p>i need some help about my code. How do i use php if statement in jquery script? 
  Without php is working just fine, but i need those conditions anyway.
  So any suggestions?</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $( document ).ready(function(){
  
  $(&lt;?php if(isset($banner_1)) :?&gt;
     "&lt;div class='banner1' id='banner_top' &lt;?php if($banner_1-&gt;on_off == 0) :?&gt;
      style='display: none' &lt;?php endif ;?&gt;&gt;" +
     "&lt;img  id='banner_top_img' class='img-responsive' 
      src='"&lt;?=base_url('assets/img/'.$banner_1-&gt;userfile);?&gt;"' alt='image'&gt;" +
     "&lt;/div&gt;" 
  &lt;?php endif ;?&gt;).insertAfter($("#latest div:eq(2)"));
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>So this is working without conditions </p>
  
  <pre><code>$( document ).ready(function(){
  
  $(
  "&lt;div class='banner1' id='banner_top' &gt;"+
  "&lt;img  id='banner_top_img' class='img-responsive' src='&lt;?=base_url('assets/img/'.$banner_1-&gt;userfile);?&gt;' alt='image'&gt;" +
  "&lt;/div&gt;").insertAfter($("#latest div:eq(2)"));
  
  });
  &lt;/script&gt;
  </code></pre>