<script type="text/javascript">
InitFirstImage(imageId);
</script>
<img id="1" class="details" width="50" height="50" src="....">
<img id="2" class="details" width="50" height="50" src="....">
...
<img id="99" class="details" width="50" height="50" src="....">
I need to know first img id(this numbers will be generated dynamicly and it will be stored in collection), so I need to know that Id and pass that value to InitFirstImage() js.
Second question
How can I in js receive that imageId and use that value for some operation, alert for example, on calling script, not onclick event.
Update:
Now when I have first img Id how can I use it for clone() function.
var clone = $(this).clone();
Can I use this for something like
var firstImageId = $("img.details").first().attr("id");
var clone = $(firstImageId).clone(); //this doesn't work.
Thank you all.
and make sure you call the InitFirstImage method in the document ready
Here is the sample : http://jsfiddle.net/2M2Dp/1/
UPDATE : Since the OP updated his question to do a clone of the first image
To get a clone of first image, use the
clone()method. The below example creates a clone of the first image with “details” class and then append to a div with id “cloneArea”Here is the working sample : http://jsfiddle.net/2M2Dp/10/
clonemethod documentation : http://api.jquery.com/clone/