title: How to change the <img> attr SRC with jQuery on wordpress, since it have <?php bloginfo( 'template_url' ) ?>
body: <p>I want to change image attr src on wordpress with click. It works perfectly offline, however, not on wordpress.</p>
  <p>the buttons to click</p>
  <pre><code>&lt;ul&gt;
  &lt;li class=&quot;bt-color&quot;&gt;
  &lt;img src=&quot;&lt;?php bloginfo( 'template_url' ) ?&gt;/img/blue.png&quot; alt=&quot;blue&quot;&gt;
  &lt;/li&gt;
  &lt;li class=&quot;bt-color&quot;&gt;
  &lt;img src=&quot;&lt;?php bloginfo( 'template_url' ) ?&gt;/img/purple.png&quot; alt=&quot;purple&quot;&gt;
  &lt;/li&gt;
  &lt;li class=&quot;bt-color&quot;&gt;
  &lt;img src=&quot;&lt;?php bloginfo( 'template_url' ) ?&gt;/img/pink.png&quot; alt=&quot;pink&quot;&gt;
  &lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  <p>the image to change is</p>
  <pre><code>//offline
  &lt;label for=&quot;id1&quot;&gt;
  &lt;img src=&quot;img/main-image.png&quot; /&gt;
  &lt;/label&gt;
  
  //online with wordpress
  &lt;label for=&quot;id1&quot;&gt;
  &lt;img src=&quot;&lt;?php bloginfo( 'template_url' ) ?&gt;/img/main-image.png&quot; /&gt;
  &lt;/label&gt;
  </code></pre>
  <p>The code to change</p>
  <pre><code>/* offline code */   
  $('.bt-color').click(function() {
      var alt = ($(this).children().attr('alt'));
      if ( alt === 'blue' ){
          $(&quot;label[for='id1']&quot;).children().attr('src', 'img/main-image-blue.png' );
      } else if ( alt === 'purple' ){
          $(&quot;label[for='id1']&quot;).children().attr('src', 'img/main-image-purple.png' );
      }
  });
  
  /* online with wordpress, my failed trial */   
  jQuery('.bt-color').click(function() {
      var alt = (jQuery(this).children().attr('alt'));
      if ( alt === 'blue' ){
          jQuery(&quot;label[for='id1']&quot;).children().attr('src', '&lt;?php bloginfo( 'template_url' ) ?&gt;/img/main-image-blue.png' );
      } else if ( alt === 'purple' ){
          jQuery(&quot;label[for='id1']&quot;).children().attr('src', '&lt;?php bloginfo( 'template_url' ) ?&gt;/img/main-image-purple.png' );
      }
  });
  </code></pre>
  <p>Doing offline it works, however, online on server, it doesn't replace the image...</p>
  <p>how can I fix that? I thank everyone for reading and try to help.</p>