附加多个项Jquery

时间:2014-05-15 20:02:47

标签: javascript jquery append

我只是想知道如何将div上的多个项目附加到另一个上面:

我想在附加内容中重新创建此内容,但我不知道如何在以下内容中添加多个项目:

<li class="listnone border_bottom_grey thin">
    <div class="circle"><i class="icon-pin"></i></div>
    <span class="grey bold inline quarter_padding_left">
    name variable would go here</span>
    <span class="small right white tag_price">price variable would go here</span></br>
    <span class="quarter_padding_top inline lightgrey small">
    <i class="icon-location-2 indent20 small"> </i> location variable would go here</span>
</li>

的Javascript

function reDrawList (){
var price = $('#tag_price');
var location = $ ('#tag_location');
var name = $ ('#tag_name');

$( ".scrollable" ).after( [price, location, name]);
};

1 个答案:

答案 0 :(得分:0)

您可以使用jQuery的.add()将它们链接到一个选择器中:

var $one = $('<li>one</li>');
var $two = $('<li>two</li>');
var $three = $('<li>three</li>');

$('ul').after($one.add($two).add($three));