Solved

Wordpress JQuery Conflict

Posted on 2014-03-24
1
300 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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
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 manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be IPage.com Log into your Hosting account. IPage will be used for demonstration : Locat…
This video teaches users how to migrate an existing Wordpress website to a new domain.

789 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