我使用此代码创建旋转木马项目单个图像
$.getJSON('index.php?callback=?','&option=com_jea&task=properties.test&format=json',function(res){
var carousel = $('<div/>',{ 'class': 'carousel-inner'})
{
$.each(res, function(i, data) {
var item = $('<div/>',{ 'class': 'item'})
$('<div class="span2">'+res[i].My Image+'</div>').appendTo(item );
item.appendTo(carousel);
})
carousel.appendTo('#myCarousel');}})
HTML
<div id="myCarousel" class="carousel slide"> <div class="carousel-inner">
<div class="item">my image</div>
<div class="item">my image</div></div>
我想在项目中输入默认数量的图像,如下所示:
<div id="myCarousel" class="carousel slide"> <div class="carousel-inner">
<div class="item"><ul><li>my image</li><li>my image</li></ul></div>
<div class="item"><ul><li>my image</li><li>my image</li></ul></div>
<div class="item"><ul><li>my image</li><li>my image</li></ul></div></div></div>