Christos Maris Christos Maris - 3 months ago 4
HTML Question

jQuery not running locally

I have the following links declared inside the head tag:

<script type="text/javascript" src="javascript/jquery-3.1.0.min.js"></script>
<script type="text/javascript" src="javascript/scripts.js"></script>


And the following code inside the scripts file:

$("#person").hover(function() {
// trigger the mouseover event
$("#person-text span").addClass("important-info");
}, function() {
// trigger the mouseout event
$("#person-text span").removeClass("important-info");
});

$(document).ready(function(){
console.log( "ready!" );
});


I have also tried adding the jQuery library through Google and Microsoft CDNs, but it didn't work as well.

Here is a screenshot from the console errors:
enter image description here

Answer

I got simile type of problem some days Earlier . I moved the custom script tag at the end of the HTML page . Then the code worked .

<script type="text/javascript" src="javascript/scripts.js"></script>

Move this line to the End of your Html page , that May work . It happens for $(document).ready() function .