title: Populate an input field with an image src in javascript
body: <p>I have an XHR response that returns images. I have my function in order to show the images. I am combining JQuery and JS in the same code snippet. So far all is working well:</p>
  
  <pre><code>function resultat(o){  
            var leselements = o.query.results.bossresponse.images.results.result;
            var output = '';  
            var no_items = leselements.length;  
            for(var i=0;i&lt;no_items;i++){  
              var lien = leselements[i].url;
  
              //place image urls in img src  
              output += "&lt;img src='" + lien + "' class='imgs'&gt;";  
            }  
            // Place images in div tag  
            document.getElementById('results').innerHTML = output;}
  </code></pre>
  
  <p>But I would like to allow users to click an image and then populate an input field ('#imageurl') with the clicked image src. Here is what I tried but it does not work.</p>
  
  <pre><code>$('.imgs img').click(function(){
              $('#imageurl').val() = "";
              var source = $(this).attr('src');
              $('#imageurl').val() = source;    
            });
  </code></pre>
  
  <p>Any help will be greatly appreciated. TIA.</p>