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

 

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.