【问题标题】:Wordpress with datepicker带有日期选择器的 Wordpress
【发布时间】:2015-12-16 00:08:32
【问题描述】:

这里myrussiaonline

在我的网站上,您可以在顶部滑块下看到表单。第一个输入带有 id datepicker。所以我需要在这个输入中调用 datepicker,但它不起作用。 在函数 php 中包含:

    <?php
wp_enqueue_script('jquery-ui-datepicker');
wp_enqueue_style('jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css');
?>

在页脚中:

    jQuery(document).ready(function() {
    jQuery('#datepicker').datepicker({
        dateFormat : 'dd-mm-yy'
    });
});

我的意见:

<input id="datepicker" style="height:15px;border:0; border-radius:0; width: 90px; position:relative;left: 50px; top: 31px; background: #E8E8E8; color: black;" type="text" name="datepicker" value="" class="hasDatepicker">

我还检查了 ui 核心和 css 文件以及我网站上加载的 datepicker.min.js,但我的输入没有反应。它仍然忽略日期选择。那我做错了什么?

【问题讨论】:

  • 在此处验证您的页面 html freeformatter.com/html-validator.html
  • 验证一下。但我不知道它将如何帮助解决我的问题
  • 我建议你修复谷歌地图问题。它可能不相关,但因为它是javascript,所以你永远不能太谨慎。 javascript 问题被链接了..
  • 另外,我不确定,但我认为您主题上的 nicescroll.js 会产生一些问题(至少在我的萤火虫控制台上)

标签: jquery wordpress jquery-ui datepicker


【解决方案1】:

我认为您需要在操作中添加脚本wp_enqueue_scripts。请参考以下代码:

function my_theme_script(){
    wp_enqueue_script('jquery-ui-datepicker');
    wp_enqueue_style('jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css');
}    
add_action( 'wp_enqueue_scripts', 'my_theme_script');

【讨论】:

    猜你喜欢
    • 2018-06-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-25
    • 2015-11-02
    • 2016-02-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多