简体   繁体   English

使用jQuery在最后一个图像之后附加HTML

[英]appending html after the last image using jquery

How do i append the following html after the last img: 如何在最后的img之后附加以下html:

//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>

尝试这个:

$('div.lookup-image-wrapper > img:last').after('<div class="icon"></div>'); 

To append content after the last image, use the last selector (:last) 要在最后一张图像后附加内容,请使用最后一个选择器(: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/ 如果您要附加的内容很多,可以在http://www.willpeavy.com/minifier/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM