嘿,伙计们,这个代码看起来真的很正确,我只是为了我的生活,不确定它对我不起作用的是什么。我正在使用flickr api记录一些照片,并使用jquery将它们放入coinslider中。图像显示良好,但没有滑块();//!
下面是我正在使用的代码:
index.js
$('document').ready(function(){
$.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?",{tags: "wild",tagmode: "any", format: "json" },
function(data) {
$.each(data.items, function(i,item){
console.log(item)
$("<img/>").attr({src : item.media.m.replace('_m.','.')}).appendTo("#pics");
if ( i == 10 ) {
$('#pics').coinslider();
return false;
}
});
});
});和我的主文件
page.html
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title></title>
<link href="css/custom.css" rel="stylesheet">
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<p id="pics">
</p>
<body>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="index.js"></script>
</body>
</html>错误是
Uncaught TypeError: undefined is not a function发布于 2014-12-04 17:00:03
更改此设置:
$('document')要这样做:
$(document)您不应使用任何引号将文档关键字括起来。
这也可能是一个路径问题,因为我看到你引用了一个js文件夹,而你没有包括coinslider js lib,所以问题可能在这里:
<script type="text/javascript" src="thePath4CoinSlider.js"></script>您可能已经将所有的js文件放在js文件夹中,并且没有从那里引用它们。
<script type="text/javascript" src="index.js"></script>检查上面脚本中的src。
https://stackoverflow.com/questions/27289556
复制相似问题