Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Wordpress JQuery Conflict

Posted on 2014-03-24
1
Medium Priority
?
309 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 58

Accepted Solution

by:
Gary earned 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The purpose of this video is to demonstrate how to properly insert a Vimeo Video into a WordPress site or Blog. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp…
This video teaches users how to migrate an existing Wordpress website to a new domain.
Suggested Courses

618 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