euDennis
euDennis

Reputation: 327

jQuery conflict with an plugin?

I had an blog using WordPress. I got an jQuery code to make some div fixed after some scroll, got it here: http://jqueryfordesigners.com/fixed-floating-elements/

Someday ago, I got an plugin to make and "Recent Post Slider" for WordPress. But when I activate it, the fixed div jQuery stop working. I think that can be an conflict, but really don't have sure yet.

What is the best move to know what's happening?

Upvotes: 0

Views: 141

Answers (4)

Evan Levesque
Evan Levesque

Reputation: 3203

make sure that you've included Jquery once but no more

Upvotes: 0

PiTheNumber
PiTheNumber

Reputation: 23542

I don't think that jQuery does not work anymore as @nicowernli said. But it is possible that the plugin changed the html of the page.

The best move is to disable the "Recent Post Slider" plugin and check if the fix starts working again. Then you will know what where problem is.

Upvotes: 0

wdev
wdev

Reputation: 2220

Get a browser with JavaScript debugger console and make it print you the $ variable. jQuery returns : function (a,b){return new e.fn.init(a,b,h)}. The $ variable is sometimes used by other libraries, and if you use it directly in your jQuery it may get overwritten. To avoid this, encapsulate your jQuery code:

(function($) {
  your code with $
})(jQuery)

This may break some of your global variables though, it depends on how you wrote your code.

Upvotes: 2

nicowernli
nicowernli

Reputation: 3348

You can use jQuery.noconflict() for this. For example:

$j = jQuery.noConflict();
$j("your_div").css("position", "fixed");

Here you have the code explanation. jQuery.noConflict

Upvotes: 4

Related Questions