Jquery Multiple load in a DIV

前端 未结 6 411
一个人的身影
一个人的身影 2020-12-08 08:45

Here is my code:

$(\'#right\').load(\'textes.html #nicolas\');
$(\'#right\').load(\'textes.html #antoine\');

The problem is that the content

6条回答
  •  没有蜡笔的小新
    2020-12-08 09:20

    WHy not load them both in one call:

    $('#right').load('textes.html #nicolas,#antoine');
    

    EDIT
    Inspired by Justice way I thought of the follwoing:

    var $page = $('
    ').load('textes.html #nicolas,#antoine'); var $nicolas = $page.find('#nicolas'); var $antoine = $page.find('#antoine'); $('#right') .html($nicolas) .append('
    ') .append($antoine);

    This will make only one (or two, depending on what firefox feels like) calls to the server. Thus saving bandwidth. But it also gives you more freedom in how to insert the elements and in which order.

提交回复
热议问题