-
Book Overview & Buying
-
Table Of Contents
WordPress 3.0 jQuery
Because WordPress and jQuery are anticipating other libraries to be loaded which may use the short variable, $. The wp_enqueue_script ensures jQuery is loaded up in noConflict mode. Therefore, you'll also need to make sure to write your custom jQuery code in noConflict mode's syntax. The easiest way to do this is to replace the $ variable (common in many jQuery scripts) with the full jQuery variable, as I've discussed in Chapter 1, Getting Started: WordPress and jQuery, and done in my two previous samples.
If you find the jQuery variable tedious to write out, yet want to remain in noConflict mode, you can replace the standard $ variable to any variable you want as follows:
<script type="text/javascript"> var $jq = jQuery.noConflict(); $jq(document).ready(function() { $jq("p").click(function() { alert("Hello world!"); }); }); </script>
You should not use the $ variable for jQuery within...
Change the font size
Change margin width
Change background colour