我想在代码中添加backstretch。
这是一个脚本:
<script>
// To attach Backstrech as the body's background
jquery.backstretch("/form-3/assets/img/backgrounds/1.jpg");
// You may also attach Backstretch to a block-level element
jquery.(".foo").backstretch("/form-3/assets/img/backgrounds/1.jpg");
// If your element defines a background image with CSS, you can omit the argement altogether
//$(".foo").backstretch();
// Or, to start a slideshow, just pass in an array of images
jquery.(".foo").backstretch([
"/form-3/assets/img/backgrounds/1.jpg",
"/form-3/assets/img/backgrounds/2.jpg",
"/form-3/assets/img/backgrounds/1@2x.jpg"
], {duration: 4000});
</script>
//I have included the scripts here
<script src="/form-3/assets/js/jquery-1.11.1.min.js"></script>
<script src="/form-3/assets/js/jquery-1.11.1.js"></script>
<script src="/form-3/assets/bootstrap/js/bootstrap.min.js"></script>
<script src="/form-3/assets/js/jquery.backstretch.min.js"></script>
<script src="/form-3/assets/js/jquery.backstretch.js"></script>
<script src="/form-3/assets/js/scripts.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"> </script>在打开这个html页面时,我想动态地更改图像。但这是在说
Uncaught type error. $backstretch is not a function.
我们怎么能把它包括进去?或者还有其他方法来动态地改变图片呢?
发布于 2017-02-09 06:12:09
在初始化scripts之后,您将包括plugin,这是上述error的实际原因。只需在任何js之前移动所有脚本
<script src="/form-3/assets/js/jquery-1.11.1.min.js"></script>
<script src="/form-3/assets/bootstrap/js/bootstrap.min.js"></script>
<script src="/form-3/assets/js/jquery.backstretch.min.js"></script>
<script src="/form-3/assets/js/jquery.backstretch.js"></script>
<script src="/form-3/assets/js/scripts.js"></script>
<script>
// To attach Backstrech as the body's background
jquery.backstretch("/form-3/assets/img/backgrounds/1.jpg");
// You may also attach Backstretch to a block-level element
jquery.(".foo").backstretch("/form-3/assets/img/backgrounds/1.jpg");
// If your element defines a background image with CSS, you can omit the argement altogether
//$(".foo").backstretch();
// Or, to start a slideshow, just pass in an array of images
jquery.(".foo").backstretch([
"/form-3/assets/img/backgrounds/1.jpg",
"/form-3/assets/img/backgrounds/2.jpg",
"/form-3/assets/img/backgrounds/1@2x.jpg"
], {duration: 4000});
</script> jquery-1.11.1.min.js 不包括对同一个文件的多个引用,因为您已经多次包含了对、、的引用。
我还觉得这些行jquery.(".foo")必须是jquery(".foo")。无.后jquery
https://stackoverflow.com/questions/42129384
复制相似问题