【发布时间】:2014-09-25 01:26:54
【问题描述】:
我正在使用以下插件在 IE8 和 IE9 中显示占位符。我认为它在去年奏效了,而现在却没有:
https://github.com/mathiasbynens/jquery-placeholder
实际上,这个插件在演示页面上完美运行:http://mathiasbynens.be/demo/placeholder
我真的不知道如何解决它。我在 WordPress 中使用它,我在其中加载本地 jQuery,如果我记得很清楚,这通常是最后一个版本。我在functions.php上将脚本排入队列:
function szt_load_scripts() {
wp_enqueue_style( 'style', get_stylesheet_uri() );
wp_enqueue_style( 'shortcodes', get_stylesheet_directory_uri() . '/shortcodes.css' );
wp_enqueue_script('jquery');
if ( is_singular() ) {
wp_enqueue_script( 'comment-reply' );
}
if (ot_get_option('szt_enable_linkbuilding') === "on") {
wp_deregister_script( 'link-building-pro-min' );
wp_register_script( 'link-building-pro-min', get_template_directory_uri().'/jquery/link-building-pro/link-building-pro-min.js', array(), true, true);
wp_enqueue_script( 'link-building-pro-min' );
}
wp_enqueue_script('scripts', get_stylesheet_directory_uri() . '/jquery/scripts.js');
wp_localize_script('scripts', 'contactForm', array(
'youForgot' => __('<span class="errormsg">You forgot to enter your ', 'wptheme'),
'invalidEmail' => __('<span class="errormsg">You entered an invalid email.</span>', 'wptheme'),
'messageSent' => __('<p class="thanks"><strong>Thanks!</strong> Your message was successfully sent.</p>', 'wptheme')
));
}
add_action('wp_enqueue_scripts', 'szt_load_scripts');
我是否以错误的方式加载插件? 我需要使用旧版本的 jQuery 吗? 我需要为此添加不同的修复程序吗?
【问题讨论】:
-
您在错误控制台中看到了什么(如果有的话)?
-
您可以转到页面并查看源代码以确保脚本甚至已添加到页面中吗?另外仅添加脚本是不够的,您还需要在
document.ready中运行$('input, textarea').placeholder();。 -
我不知道如何使用错误控制台,@TiesonT。
-
@Gerard 按 F12 键。
-
@TiesonT。它有一个错误:“未捕获的 TypeError:无法读取未定义 measureIt.js:120(匿名函数)的属性 'create'”。但它属于不是主题的文件 measureIt.js。
标签: jquery wordpress placeholder