jquery - 在 WordPress 中使用 Jquery 倒计时

标签 jquery wordpress countdown

我正在尝试在 WordPress 中使用 keith wood 的 jquery 倒计时器,但运气不佳。我在非 WordPress 网站上使用过它,没有任何问题。

以下是我的 WordPress header.php,计时器根本不显示。

<!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>
        </div>
    <?php wp_nav_menu(); ?>    
    </div>
    <div id="main">

任何想法我做错了什么,因为它让我疯狂地试图修复它。

最佳答案

试试这个

var $j = jQuery.noConflict();

$j(function(){
    var endOfTrading = new Date ( 'June 30, 2011 18:00:00' );
    $j('#defaultCountdown').countdown({until: endOfTrading});

});

你需要将 jquery 设置为 noconflict...希望这能解决它。 :-)

关于jquery - 在 WordPress 中使用 Jquery 倒计时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6487452/

相关文章:

php - 如果未登录,则重定向到首页 WordPress

php - 当用户更改系统时间时,jquery 倒计时会发生变化

javascript - 循环 Javascript 计时器

javascript - 使用 PHP 和 Javascript 的多次拍卖倒计时

javascript - 删除该元素时,Html 元素的事件不会被删除

javascript - 高分辨率图像加载时的图像闪烁

mysql - SQL 基于另一行更新行

javascript - 如何加载本地 JSON 并将其保存到变量中

javascript - jQuery(或 javascript)验证日期范围

php - 将 Wordpress functions.php 中的代码仅应用于一个类别