I am using a JQuery plugin tiksluscarousel. It works fines for static html code. which is shown in .

我正在使用JQuery插件tiksluscarousel。它对静态HTML代码起作用。显示在。

<div id="fruits">
    <ul>
        <li><img src="http://tikslus.com/web/bundles/tikslustikslus/examples/carousel/fruits1.jpg" /></li>
        <li><img src="http://tikslus.com/web/bundles/tikslustikslus/examples/carousel/fruits2.jpg" /></li>
        <li><img src="http://tikslus.com/web/bundles/tikslustikslus/examples/carousel/fruits3.jpg" /></li>
        <li><img src="http://tikslus.com/web/bundles/tikslustikslus/examples/carousel/fruits4.jpg" /></li>  
    </ul>
</div>
$('.page-content-area').ace_ajax('loadScripts', scripts, function() {  

    jQuery(document).ready(function(){
        $("#fruits").tiksluscarousel({width:640,height:480,nav:'thumbnails',current:1});
    });  
});  

Then i want to load images from a JSON. Then the slider effects gone. which is

然后我想从JSON加载图像。然后滑块效果消失了。是的

<div id="fruits1"></div>
var data = {"data": [{ 
        "name": "Nike air foamposite \"hyper colbalt/ben gordan\" pre order 8/26",
        "imagepath": "http://tikslus.com/web/bundles/tikslustikslus/examples/carousel/fruits3.jpg"
    },
    { 
        "name": "Nike air foamposite \"hyper colbalt/ben gordan\" pre order 8/26",
        "imagepath": "http://tikslus.com/web/bundles/tikslustikslus/examples/carousel/fruits2.jpg"
    },
    { 
        "name": "Nike air foamposite \"hyper colbalt/ben gordan\" pre order 8/26",
        "imagepath": "http://tikslus.com/web/bundles/tikslustikslus/examples/carousel/fruits1.jpg"
    },
    { 
        "name": "Nike air foamposite \"hyper colbalt/ben gordan\" pre order 8/26",
        "imagepath": "http://tikslus.com/web/bundles/tikslustikslus/examples/carousel/fruits4.jpg"
    } 
]}  
var node = document.getElementById("fruits1") 
for (var i in data.data) {   
    var newItem = document.createElement("li");  
    var img = document.createElement("img");
    img.src = data.data[i].imagepath;  
    newItem.appendChild(img);    
    node.appendChild(newItem);   
}

$('.page-content-area').ace_ajax('loadScripts', scripts, function() {  

    jQuery(document).ready(function(){ 

$("#fruits1").tiksluscarousel({width:640,height:480,nav:'thumbnails',current:1});       
    });
}); 

I can not find the reason why the effect gone. Please help me.

我找不到效果消失的原因。请帮帮我。

1 个解决方案

#1


1

var node = document.getElementById("fruits1") will return the div not the ul. you have to append the li to the ul child of div.

var node = document.getElementById(“fruits1”)将返回div而不是ul。你必须把李附加到div的ul子。

try

var node = document.getElementById("fruits1").child[0];

instead of var node = document.getElementById("fruits1")

而不是var node = document.getElementById(“fruits1”)

hope this helps.

希望这可以帮助。

更多相关文章

  1. extjs4 desktop 实现仿win7效果的桌面窗口预览效果
  2. 原生javascript-图片弹窗交互效果
  3. 炫酷的手风琴效果
  4. AJAX内容更改加上小变化效果
  5. 动态更改angularjs中静态段落的颜色
  6. 每次在HTML5中加载静态图像
  7. JavaScript 利用 async await 实现 sleep 效果
  8. 尝试用jQuery创建旋转木马效果
  9. Python网页静态爬虫

随机推荐

  1. Visual Studio跨平台开发实战(4) - Xamar
  2. Android——textView
  3. Android系统编译系统分析大全(一)
  4. Unity调用Android配置方法
  5. System.out.println()和Log耗时之比
  6. Android顶部工具栏和底部工具栏的简单实
  7. [android]控件ImageView的常用属性
  8. Android 从零开始打造异步处理框架
  9. LinearLayout中实现水平方向上的两个text
  10. 最全的PHP开发Android应用程序