/ / Uncught TypeError: $ .backstretch ist keine Funktion - Jquery

Uncaught TypeError: $ .backstretch ist keine Funktion - jquery

ich will hinzufügen backstretch in meinem Code.
Dies ist das Skript:

<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="/images//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>

Ich möchte die Bilder dynamisch ändern, wenn wir diese HTML-Seite öffnen. Aber es heißt

Uncaught type error. $backstretch is not a function.

Wie können wir es aufnehmen? Oder gibt es andere Möglichkeiten, die Bilder dynamisch zu ändern?

Antworten:

1 für die Antwort № 1

Sie schließen ein scripts nach dem initialisieren der plugin Das ist der eigentliche Grund für das oben error. Verschieben Sie einfach alle Skripts vor 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>

Fügen Sie nicht mehrfache Verweise auf dieselbe Datei ein, wie Sie sie angegeben haben jquery-1.11.1.min.js mehrmals.

Auch ich fühle, dass diese Zeilen jquery.(".foo") muss sein jquery(".foo"). Nein . nach jquery