How to use jQuery noConflict to prevent conflicts with other scripts

JavaScript
// jQuery

What it does

If your jQuery script isn’t working, especially in a WordPress site, this might be caused by a conflict with your jQuery selector. There’s an easy fix for this.

The Code

$j=jQuery.noConflict(); // Create an alias for jQuery

$j(document).ready(function() { // Use this alias in place of the '$' from here onwards
	$j('#buttonID').click(function() {      
		$j(this).doSomething(); // Replace this with your action
	})
});

How To Use It

Paste this snippet into a JavaScript file that is loaded by your page, or you can put it between <script> </script> tags in the footer.

jQuery is required.

Menu