Jquery is not working

Asked

Viewed 321 times

0

I’m having trouble making jquery work. Here’s the head of my HTML:

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<link rel="script" type="text/javascript" href="script.js">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="style.css">

And here’s my javascript:

    $(document).ready(function() {

    var currentPosition = 0;
    var slideWidth = 580;
    var slides = $(".movie");
    var numberOfSlides = slides.length;
    var slideShowInterval;
    var slideshowSpeed = 3000;

    slideShowInterval = setInterval(changePosition, slideshowSpeed);
    slides.wrapAll("<div id="slidesHolder"></div>");
    slides.css({"float": "left"});
    $("#slidesHolder").css("width", slideWidth * numberOfSlides);


    function changePosition() {
            if (currentPosition == numberOfSlides) {
                currentPosition = 1;
            }
            else {
                currentPosition += 1;
            }
            moveSlide();
    }

    function moveSlide() {
        $("#slideHolder").animate({"marginLeft": slideWidth * (-currentPosition)});
    }

});

The strange thing is that I’ve used Jquery in exactly the same way on other sites before, and it worked perfectly. I’ve done the test of alert, I tried to use the downloaded library instead of Google CDN, I tried to change the order of <script> in head HTML, and I’ve searched for the same problem on other forums, but unsuccessfully getting help.

1 answer

4

Your error is not loading Jquery, but syntax error:

Uncaught Syntaxerror: Missing ) after argument list.

In the slides.wrapAll which you are using, the quotation marks need to be removed "" when placing the id of div.

Just use the \ to take the value of quotes, or you can use quotes ':

slides.wrapAll("<div id=\"slidesHolder\"></div>");

Jsfiddle functional.

  • Thanks for the warning, but jquery is still not working. I took the Alert() test; and nothing happens.

  • Make F12 and see the error that is on the console

  • Your answer is here: http://jsfiddle.net/ivanferrer/fdgnnhz1/1/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.