Jump to content

How do you include jquery in an html page?


floridaflatlander

Recommended Posts

I'm using a plugin to include a photo gallery on a wordpress site.

 

At the bottom of the page in the footer I include

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

just like the samples I look at do it here http://getbootstrap.com/getting-started/#examples

 

The problem is that the plugin doesn't work when I include jquery.

I posted the probelm here https://wordpress.org/support/topic/huge-it-doesnt-work-with-google-ajax-jquery

 

And the reply was

 

jQuery should not be called this way. You try to call jQuery in no standard way, that's why it damages or jQuery and cause problems

 

jQuery should not be called this way? That's the way the samples do it

You try to call jQuery in no standard way? It's the same in every footer

 

Sooo, how do you call jquery and what is the standard way?

 

Thanks in advance

 

 

 

Thanks fastsol

 

I believe jquery is needed for the bootstrap menu and for hide divs to work although they seem to work without it.

I use an if (is_page( 'gallery' )) to include it jquery in the header and (!(is_page())) to exclude it in the footer on the gallery page.

 

Thanks again

The reply to your post on WordPress forum is probably due to the fact that this isn't the WordPress way of including the jQuery library. Also, check to make sure that WordPress isn't already including it. WP installs a local copy of jQuery in non-conflict mode in order to lessen the chances of conflicts when two different plugin developers use different libraries. You can always dequeue the WP version and enqueue the newer version, but be ware that it may actually break things. Like apparently Huge-it.

 

WordPress is like that.

 

Dequeue a script.

Enqueue a script.

  • 2 weeks later...

The jQuery library is a single JavaScript file, and you reference it with the HTML <script> tag (notice that the <script> tag should be inside the <head> section

 

  • First way

                 Download the jQuery library from jQuery.com

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

  • Second way

                Include jQuery from a CDN, like Google

 

                  <head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
</head>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.