Where Does jQuery Go?
-
This is not a theme related question.
I am using Headway Theme, which in it’s developer options has an option to automatically activate several jQuery libraries site-wide (which automatically are included into the header of every page).
Now I posted originally on Headway’s support forum and received an extremely cryptic answer and I was told to come here.
My questions are as follows:
1. Since my theme automatically activates the libraries, that means that all I have to do is add my jQuery function scripts to my site right? In other words, there is no reason to use wp_enqueue function in custom functions.php to register jQuery for various pages right?
2. Where do the PHP conditional page tags go and where do the jQuery scripts go? Do they all go in custom functions.php?
Such as this jQuery script…
$(document).ready(function() { $("div.headway-leaf-inside:has(div.page)").addClass("cj-pagepad"); });
…which adds some padding to the interior of an element based on whether or not it has an ancestor of div.page. Which as of now can only be done using the :has selector in jQuery (and of course I will need jQuery for many other functions).
Or these PHP conditional tags (these are just a wild guess):
<?php if( !is_page(5) ) wp_enqueue_script ( 'myjquery', get_bloginfo(' what goes here?').'/myjquery.js', array('jquery') ); ?>
or…
<?php if( is_page( 5 ) ) { ?> <scrpt type=' something here ' src= '/myjquery.js'> </scrpt>
3. How would I use conditional page tags in conjunction with it so that I can apply certain functions only to certain pages?
4. How would the sample code blocks be written (in full) so I can get a complete picture so my code blocks validate without error?
Excuse my ignorance, but I’m just getting started with jQuery and WordPress.
- The topic ‘Where Does jQuery Go?’ is closed to new replies.