English 中文(简体)
Using jQuery Plugins with Wordpress
原标题:

Having a bit of trouble using jQuery plugins (Superfish, jQuery UI, etc) using Wordpress. Everything works fine in my plain non-Wordpress site, but Wordpress seems to conflict with JQuery. There must be some way to get around this.

Also, I m using Carrington Framework, if that makes a difference.

In Safari s web inspector, I get these errors:

ReferenceError: Can t find variable: jQuery
ReferenceError: Can t find variable: $
问题回答

Wordpress and jQuery wouldn t conflict with each other. Wordpress is on the server, jQuery is on the client and aside from dealing with the HTML returned by Wordpress the two don t really have much to do with each other. You would get that error if the javascript that defines the jQuery object wasn t properly loaded / parsed by the browser. Three troubleshooting solutions:

  1. Check and make sure that your client is making the request for the jQuery javascript file. If not then the script tag requesting the file may not be included correctly in your page.
  2. If it is making the request, make sure it s successful. If the response is a 404 code or some other error, fix whatever is causing it (bad url, incorrect permissions, ect.)
  3. I ve noticed that when using the minified version of jQuery, the browser occasionally throws an error when trying to parse the code, leading to the reference error you are experiencing when you try to use the jQuery function later in the code. If you are using the minified version of jQuery, try switching to the uncompacted version and see if that solves your problem.

Just put all of your js under the

<?php
    wp_head(); 
?>

section. If you have any problems in individual files, all the line:

var $j = jQuery.noConflict();

to the top.





相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签