Error in reference : Variable was not defined

Asked

Viewed 130 times

1

Because it has error in the variable if in a fiddle ( -> http://jsfiddle.net/8xwqdk71/ <- ) does not present this error?
Can it be anything other than Js libraries? Because they have all been defined
(Code that when clicking, rotates the image)

var value = 0
$("#image").rotate({
  bind: {
    click: function() {
      console.log(value);
      value += 90;
      $(this).rotate({
        animateTo: value
      })
    }
  }

});
#image {
  margin: 100px 100px;
}
<script src="http://beneposto.pl/jqueryrotate/js/jQueryRotateCompressed.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js"></script>
<script src="https://raw.githubusercontent.com/wilq32/jqueryrotate/master/jQueryRotate.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<img src="https://www.google.com/images/srpr/logo3w.png" id="image">

  • Sorry, reference, accuses this error : "Uncaught Referenceerror: $ is not defined"

  • 1

    It was necessary to include the jQuery https://code.jquery.com/jquery-3.2.1.min.js

  • I put the 2.1.1, now it is giving error in the function Rotate, need to matter more things right?? (for on the site of Jqueryrotate asked to import only this and those who already have

1 answer

1


Just reverse the order of the script calls, and call jQuery before all.

Thus:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://beneposto.pl/jqueryrotate/js/jQueryRotateCompressed.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js"></script>
<script src="https://raw.githubusercontent.com/wilq32/jqueryrotate/master/jQueryRotate.js"></script>
<img src="https://www.google.com/images/srpr/logo3w.png" id="image">
  • You set :D :(

  • I think it’s because you’re using scripts that do pretty much the same thing. jquery.minjs. and the jQueryRotateCompressed.js

  • I’ll try again!! obg !!

  • If you need a reference, I put the code on Github

  • Now it worked!!! thanks @Vinicius <3

Browser other questions tagged

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