Using Jquery countdown in Wordpress
I'm trying to use keith wood's jquery countdown timer in Wordpress and not having much luck. I've used it in non-wordpress sites without any problem.
The following is my wordpress header.php and the timer is just not showing at all.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<?php wp_enqueue_script('jquery'); ?>
<?php wp_head(); ?>
<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_url'); ?>/css/jquery.countdown.css" />
<script src="<?php bloginfo('template_url'); ?>/js/jquery.countdown.js" type="text/javascript"></script>
<link href="<?php bloginfo( 'stylesheet_url' ); ?>" rel="stylesheet" type="text/css" />
<script type="text/javascript">
jQuery(function () {
var endOfTrading = new Date ( 'June 30, 2011 18:00:00' );
jQuery('#defaultCountdown').countdown({until: endOfTrading});
});
</script>
<title>Big Splash</title>
</head>
<body>
<div id="header">
<div id="header-content">
<img src="<?php bloginfo('template_url'); ?>/images/big-splash-logo.png" width="458" height="300" alt="The Big Splash" />
<div id="defaultCountdown" class="hasCountdown"></div>
开发者_StackOverflow社区 </div>
<?php wp_nav_menu(); ?>
</div>
<div id="main">
Any ideas what i'm doing wrong, as it's driving me insane trying to fix it.
try this one
var $j = jQuery.noConflict();
$j(function(){
var endOfTrading = new Date ( 'June 30, 2011 18:00:00' );
$j('#defaultCountdown').countdown({until: endOfTrading});
});
you need to set jquery into noconflict... hope this solves it. :-)
It turns out i needed to remove the class="hasCountdown" from the div. Works fine now.
精彩评论