How do i make jquery run offline? [Solved]

How do i make jquery run offline? [Solved]
0

#1

Hi folks …

My tribute page has a toggle so that menu when the screen gets small the menu becomes a button.
This functionality requires jquery.
When I am online this script takes care of this:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>

However, most of the work I do is offline.

So, I downloaded jquery-1.12.4 into the same folder as my project.
Then I added the following script to my <head>:

<script src="jquery-1.12.4/jquery.min.js"></script>

However, the menu-toggle is does not work?

This is driving me nuts! Any ideas folks?


#2

Did you place the jQuery file in a folder called jquery-1.12.4?


#3

Is the src location correct? Try an extra leading / or try the absolute file path.


#4

yes …

the actual html file path is:
portfolio/my portfolio.html

the jquery file path is:
portfolio/jquery-1.12.4/jquery.min.js


#5

Are you sure jQuery works? Try a simple script that uses jQuery, like

$("something").click(function() {
  alert("Hi");
});

Since you mentioned a menu-toggle, I assume you’re using Bootstrap. Have you downloaded Bootstrap.js?


#6

Have you tried this file path:

<script src="/jquery-1.12.4/jquery.min.js"></script>

(Note the leading /)


#7

Hi guys … Problem solved!

Swapped the order of two lines of code:

Toggle does not work:

<script src="jquery-1.12.4/jquery.min.js"></script>
<script src="bootstrap-3.3.7/js/bootstrap.min.js"></script>

Toggle does work:

<script src="bootstrap-3.3.7/js/bootstrap.min.js"></script>
<script src="jquery-1.12.4/jquery.min.js"></script>

Bizarre but true! (any idea why this is so?)

Thank you so much … thanks a lot for your suggestions, and i really appreciate the speed with which you replied - it’s really reassuring to know that when i get stuck there’s people who will help out.

All the best - Paul.

Thanks @JacksonBates
Thanks @kevcomedia


#8

Isn’t it the other way around?
Bootstrap.js depends on jQuery, so jQuery has to be loaded first.


#9

FYI I keep editing your posts so the code shows. The forum doesn’t accept raw HTML, so you need to use back ticks to format code:


#10

Ooops! You are right. This is the version that works - jquery before js:

    <link rel="stylesheet" href="bootstrap-3.3.7/css/bootstrap.min.css">
 
    <script src="jquery-1.12.4/jquery.min.js"></script>

    <script src="bootstrap-3.3.7/js/bootstrap.min.js"></script>

(Thanks for the formatting tip.)