【问题标题】:How come my simple JQuery code doesn't work? [closed]为什么我的简单 JQuery 代码不起作用? [关闭]
【发布时间】:2010-12-01 06:13:17
【问题描述】:
 <script src="http://code.jquery.com/jquery-1.4.3.js" type="text/javascript"></script>
 <script src="https://github.com/tobia/CrossSlide/raw/master/jquery.cross-slide.min.js" type="text/javascript"></script>  
<script type="text/javascript"> 
 $(function(){
                    $(".imagedivholder").each(function(e){
                        $(this).crossSlide({ speed:45, fade:1
                                },[
                                {src: $(this).attr("rel"), dir:'up' },
                                {src: $(this).attr("rel"), dir:'down' },
                                ]
                            });

                        });


            });

</script>

这些是我的 div...

<div class="awallpost"> 
            <div class="imagedivholder" rel="http://farm4.static.flickr.com/3458/3889274600_f381d28003.jpg" > 
                <!--<a href="document/show?id=4cde4c258aad69014a0000e1"><img src="http://s3.amazonaws.com/fabletest/4e0bndzxsaf3qul2" width="230" height="230"></a>--> 
                 <div class="trans_caption"> 
                     <div style="padding:6px"> 
                    The Docks and The City: ...
                    </div> 
                 </div> 
            </div> 
        </div> 

        <div class="awallpost"> 
            <div class="imagedivholder" rel="http://farm4.static.flickr.com/3454/3814350374_d37f82124b.jpg" > 
                <!--<a href="document/show?id=4cde4e1c8aad69014a00011e"><img src="http://s3.amazonaws.com/fabletest/vbparxeymqgndc8l" width="230" height="230"></a>--> 
                 <div class="trans_caption"> 
                     <div style="padding:6px"> 
                    Earth&#39;s paradise?
                    </div> 
                 </div> 
            </div> 
        </div> 

这是 CSS

.imagedivholder {
    float:left;
    position:relative;
    margin:10px;
    width:230px;
    height:230px;

}

我按照这里的所有说明进行操作: http://tobia.github.com/CrossSlide/

【问题讨论】:

  • 了解如何使用Web inspector

标签: javascript jquery css templates


【解决方案1】:

在最后一个 ] 之后,您还有一个额外的 }

【讨论】:

    【解决方案2】:

    首先,您遇到了一个简单的语法错误。

    $(function(){
        $(".imagedivholder").each(function(e){
            $(this).crossSlide({
                speed:45, fade:1
            },[
                { src: $(this).attr("rel"), dir:'up' },
                { src: $(this).attr("rel"), dir:'down' },
            ]);
        });
    });
    

    尝试学习使用Firebug。它会帮助你发现像这样的简单错误。如果您仍有问题,请告诉我们。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-05
      相关资源
      最近更新 更多