Reputation: 1654
How do i append the following html after the last img:
//create the icon
$('div.lookup-image-wrapper > div img').append('<div class="icon"></div>');
Here is my markup:
<div class="lookup-image-wrapper" style="text-align: center">
<div class="divProductPic" id="divProductPic26039">
<img alt="200 D" border="0" id="ProductPic26039" name=
"ProductPic26039" onclick="popuplarge_26039()" src=
"images/Product/medium/26039.jpg" style=
"cursor:hand;cursor:pointer;" title=
"Click here to view larger image">
</div>
<img alt="Show Picture 1" border="0" class="image-nav" onclick="_(1);" src="images/PRODUCT/icon/26039_1_.jpg"
style="cursor:hand;cursor:pointer;">
<img alt="Show Picture 2" border="0" class="image-nav" onclick="_(2);" src="images/PRODUCT/icon/26039_2_.jpg"
style="cursor:hand;cursor:pointer;"><img alt="Show Picture 3" border="0" class="image-nav" onclick="setcolorpicidx_26039(3);" src=
"images/PRODUCT/icon/26039_3_.jpg" style="cursor:hand;cursor:pointer;">
<!--[#### THE DIV ICON NEEDS TO GO HERE #####]-->
<div id="prodEmbiggen">
<a href="javascript:void(0);" onclick=""><img align="absmiddle" alt="" border="0" src="showlarger.gif" title=
"Click for larger image"></a>
</div>
</div>
Upvotes: 1
Views: 458
Reputation: 337560
Try this:
$('div.lookup-image-wrapper > img:last').after('<div class="icon"></div>');
Upvotes: 3
Reputation: 526
To append content after the last image, use the last selector (:last)
$('div.lookup-image-wrapper > div img:last').append("your content");
If you have a lot of content to append, you can minify the HTML here http://www.willpeavy.com/minifier/
Upvotes: 2