Solved

Wordpress JQuery Conflict

Posted on 2014-03-24
1
295 Views
Last Modified: 2014-04-08
I have a JQuey function that when you click a button it shows a hidden div.  I'm using word press.  

I have the Div inside of a function.  When I have the div within the HTML it opens and closes fine.  BUT now with the div inside of a function, it will not open

JQuery Function:
$(document).ready(function() {
$(':button[name^="custom_"]').click(function() {
			$(this).val("Finish Customizing");
			var x = $(this).attr("name").replace(/\D/g,"");
			x = x?"-"+x:"";
			$("#custom-hidden-1").toggle('slow');
	});});

Open in new window



PHP Function:
function checkout_fields() {

?>
<div id="custom-color-1">
<p id="company-wrap">
<span class="edd-description"><?php _e( 'Enter the name of your company.', 'pippin_edd' ); ?></span>
<input class="edd-input" type="text" name="edd_company" id="edd-company" placeholder="<?php _e('Company Name', 'pippin_edd'); ?>" value=""/>
</p>
</div>
<?php					
}

Open in new window

0
Comment
Question by:rgranlund
1 Comment
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39951865
WP uses jQuery to reference the library so you have to use jQuery and not $ - but you can pass the jQuery object into the function as $ by changing your code like so...

jQuery(document).ready(function($) {
$(':button[name^="custom_"]').click(function() {
			$(this).val("Finish Customizing");
			var x = $(this).attr("name").replace(/\D/g,"");
			x = x?"-"+x:"";
			$("#custom-hidden-1").toggle('slow');
	});});

Open in new window

0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
In order to have all security and back ups taken care of, WordPress users can sign up for services with WP Engine.
The purpose of this video is to demonstrate how to automatically show related posts at the bottom of a blog post in WordPress. This will be demonstrated using a Windows 8 PC. Plugin “Yet Another Related Posts Plugin” will be used. Go to your…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now