I must add X images to the view. Each image on click should show own input below on click.
I am getting list of images into my model. In the foreach loop I can add them dynamicly but how is it possible to make onclick function original for each one, so each input will separated for each image.
@foreach (var image in Model.Image)
{
<div class="col-md-2" style="cursor: pointer">
<img src="@Url.Content(image)" alt="image" />
<input type="text" class="form-control" style="visibility: collapse"/>
</div>
}
.click()event - e.g.$('img').click(function() { $(this).next('input').show() });- but would be better to give the elements class names and use them for the selectors.$(this).next('input')gets the next textbox associated with the image you clicked (and if you want to refer to the images, its just$(this)