I am trying to get the img src for a javascript function.
But the images were set true a foreach loop and the src of the image are send from the model like this
@{
     foreach (var image in Model.ImagesInFile)
     {
         var imageFile = "/Content/images/" + image;
         <div class="image_holder">
             <img id="img_tumb" class="images_display" src="@imageFile" alt="testimage" onclick="show_pic()" />
         </div>         
     }
 }
What I'm trying to do is when I click on an image that image should be displayed with javascript in a div that I have,
<div class="image_showcase" id="img_show">
</div>
But how do get the source of the image that is clicked ??
I tried this,
<script>
    function show_pic() {
        if ($('#img_show').find('img').length > 0) {
            alert("same image");
        } else {
            var img_src = document.getElementById('img_tumb').src;
            var img = document.createElement("img");
            img.src = img_src;
            document.getElementById('img_show').appendChild(img);
        }       
    }
</script>
But when I click on any image I will always get the first image in the list, it doesn't matter what image I clicked !?