我想在父div中追加最后克隆的div

时间:2018-12-05 19:45:04

标签: javascript jquery html css ajax

我已经在Div比较容器中克隆了Div新表格

查看代码为

<div class="cd-products-wrapper" >
        <ul class="cd-products-columns"  >
            <div id="comparecontainer">
                <li class="product" id="NewForm">
                    <div class="top-info" id="picbox">
                        <input type="button" class="btn btn-info btn-sm" id="item_detail" value="Select an Item" >
                    </div> <!-- .top-info -->

                    <ul class="cd-features-list" id="valuelist">

                    </ul>
                </li>
            </div> <!-- .product -->
            <li class="product" >
                <div class="top-info">
                    <input type="button" class="btn btn-success btn-lg" id="additem" value="MORE ITEMS" >
                </div>
                <div class="top-info">
                    <input type="button" class="btn btn-danger btn-lg" id="removeitem" value="REMOVE" >
                </div> 
            </li> 


        </ul> 

    </div> 

现在我想使用Ajax将li标签插入到is = valuelist的最后一个克隆的div标签中ul

`

$('#picbox').parent($('#comparecontainer').children().last().attr('id')).html(" ");
                $('#picbox').parent($('#comparecontainer').children().last().attr('id')).append('<img src="http://localhost/fyp/uploads/stock/'+pics[0]+'." height="200" width="200">');
                //map names to the array
                const names = arr.map(obj => obj.value);
                for (i = 0; i < names.length; i++) {
                    $('#valuelist').closest($('#comparecontainer').children().last().attr('id')).append('<li>'+names[i]+'</li>');`

                }

0 个答案:

没有答案