我想在我的代码中添加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.
我们如何包含它?或者还有其他方法可以动态更改图片吗?
答案 0 :(得分:1)
在初始化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
<iframe src="http://localhost/iframe/" frameborder="0" style="overflow-x:hidden; overflow-y:hidden; height:100%;width:102%;position:absolute;top:120px;right:-16px;" height="120%" width="102%"></iframe>