Javascript Wordpress UncaughtTypeError:undefined不是函数-Jquery标记它插件
我正在尝试使用Tagit Jquery插件, 如果有人想看,也可以附上照片 我使用此代码的页面是独立页面,由模板\重定向wordpress操作调用 我的代码是Javascript Wordpress UncaughtTypeError:undefined不是函数-Jquery标记它插件,javascript,jquery,wordpress,jquery-plugins,wordpress-theming,Javascript,Jquery,Wordpress,Jquery Plugins,Wordpress Theming,我正在尝试使用Tagit Jquery插件, 如果有人想看,也可以附上照片 我使用此代码的页面是独立页面,由模板\重定向wordpress操作调用 我的代码是 jQuery(document).ready(function($){ // Error showing here - Uncaught TypeError: undefined is not a function $('#tags').tagit({ availableTags: ["c++", "java", "php", "jav
jQuery(document).ready(function($){
// Error showing here - Uncaught TypeError: undefined is not a function
$('#tags').tagit({ availableTags: ["c++", "java", "php", "javascript", "ruby", "python", "c"]});
});
我在tag-it.source代码中也遇到了同样的错误,如下所示
$.widget('ui.tagit', {
// Error showing here - Uncaught TypeError: undefined is not a function
options: {
allowDuplicates : false,
caseSensitive : true,
fieldName : 'tags',
placeholderText : null, // Sets `placeholder` attr on input field.
readOnly : false, // Disables editing.
removeConfirmation: false, // Require confirmation to remove tags.
tagLimit : null, // Max number of tags allowed (null for unlimited).
// Used for autocomplete, unless you override `autocomplete.source`.
availableTags : [],
下面是向wordpress添加脚本的代码
function ds_enqueue_query_scripts(){
wp_enqueue_script('jQuery');
wp_enqueue_script( 'tagit',get_template_directory_uri() .'/js/tag-it.min.js', 'jquery' );
wp_enqueue_style( 'tagitcss', DSCSS . 'tagit.css');
}
add_action('wp_enqueue_scripts', 'ds_enqueue_query_scripts' );
代码显示在页眉部分,jquery在标记之前加载…我猜应该是这样的
<script type='text/javascript' src='http://myhostlocal/AgamWordpress/wp-includes/js/jquery/jquery.js?ver=1.11.0'></script><script type='text/javascript' src='http://myhostlocal/AgamWordpress/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.2.1'></script><script type='text/javascript' src='http://myhostlocal/AgamWordpress/wp-content/themes/desistation/js/main.js?ver=3.9.1'></script><script type='text/javascript' src='http://myhostlocal/AgamWordpress/wp-content/themes/desistation/js/tag-it.min.js?ver=3.9.1'></script>
您可以输入包含页面的代码吗?请确保它包含在jquery文件之后。您没有包含标记它
插件文件,或者引用顺序不正确