title: Show / hide image function with remove classname
body: <p>I'm using the following function to display the image on which the user clicks on in an above div.</p>
  
  <p>In the event the user clicks again on the populated image (in the div), I would like to remove the image in the div and have the original image visible again.</p>
  
  <pre><code>&lt;img id="&lt;?php echo $id; ?&gt;" src="img/.." url=".." name="..."  onClick="changeImage(this)"/&gt;
  
   function changeImage(item) {
        var url_img = $(item).attr('url');
        var name_item = $(item).attr('name');
         var item_id = $(item).attr('id');
         document.getElementById('test').innerHTML += '&lt;div style=\'display:inline-block\'&gt;&lt;img src=' + url_img + ' url = '  + url_img +  '  onClick=document.getElementById(' + item_id + ').classname=\'\'; /&gt; ' + name_item + '&lt;/div&gt;';     
         $(item).toggleClass('hideitem');
  }
  </code></pre>
  
  <p>.hideitem is a class with display:none;</p>
  
  <p>The onClick event in the function does not work (I was trying to remove the classname) and I'm not able to remove the div image when it is clicked with the onClick event. </p>
  
  <p>Would anyone have an idea to fix this?</p>
  
  <p>Thanks</p>