0

索引.php

<div id="carousel-image-and-text" class="touchcarousel grey-blue sbSlider">       
      <ul class="touchcarousel-container  item-list"  <?php echo "id='".$catId."'"; ?> > 
      </ul> 
</div>

js:

 $(document).live( "pagebeforecreate", function( e, data ) { 
                    $( ".item-list" ).each(function( index ) { 
                        var id = $(this).attr("id");  
                       $.ajax({ 
                            url: "/test.html",
                            context: document.body
                             }).done(function(html) {  
                               // $("#"+id).append(html); 
                              $("#"+id).replaceWith(html);
                        });  
                       // alert(id); 
                     }); 

      });

测试.html

 <li class="touchcarousel-item"><a href="gift-page.html"><span><img src="/images/spacer.gif" style="background:url(https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-ash3/p128x128/851586_168401033316275_1834897920_n.png) no-repeat center center; background-size:auto 50px"/></span><strong>Napoli</strong><font>Food and Drinks</font><label><i></i>15</label></a></li>
   <li class="touchcarousel-item"><a href="gift-page.html"><span><img src="/images/spacer.gif" style="background:url(https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-prn1/p128x128/851586_641022952579983_1053547819_n.png) no-repeat center center; background-size:auto 50px"/></span><strong>Pusheen</strong><font>Food and Drinks</font><label>FREE</label></a></li>
4

1 回答 1

0

如果我错了,请纠正我,但看起来你正在用<UL>and替换你的<LI>。所以这意味着你将只拥有<LI>一个<UL>. 在这种情况下,我认为你应该使用.append而不是.replaceWith

于 2013-08-01T11:44:52.553 回答