在WordPress中使用jQuery设置选择框的样式
只是尝试在WordPress项目上使用jQuery使用此插件设置一个选择框的样式 当我在选择框中调用它时,它会显示.newListSelected(可设置样式的列表)的两个副本,而不是一个副本。下面是用于生成选择框的代码在WordPress中使用jQuery设置选择框的样式,jquery,wordpress,jquery-plugins,drop-down-menu,Jquery,Wordpress,Jquery Plugins,Drop Down Menu,只是尝试在WordPress项目上使用jQuery使用此插件设置一个选择框的样式 当我在选择框中调用它时,它会显示.newListSelected(可设置样式的列表)的两个副本,而不是一个副本。下面是用于生成选择框的代码 <?php $args = array( 'taxonomy' => 'genre', 'id' => 'genre-dropdown', ); wp_dropdown_categories( $args ); ?>
<?php
$args = array(
'taxonomy' => 'genre',
'id' => 'genre-dropdown',
);
wp_dropdown_categories( $args );
?>
我尝试了自定义分类法,没有任何争论,在一个完全不同的页面上使用了相同的结果。原始URL已失效,我使用进行了测试。下面的示例创建一个管理菜单,该菜单显示样式化的类别下拉列表。关键的细节是加载jQuery插件,添加捆绑的WordPress脚本作为依赖项,请参阅 文件
wp content/plugins/my plugin/styled dropdown.php
:
<?php
/* Plugin Name: Styled Dropdown */
add_action( 'admin_menu', 'add_menu_so_3216591' );
function add_menu_so_3216591()
{
add_menu_page(
'SI',
'<span style="color:#e57300;">SelectIt</span>',
'edit_pages',
'so-3216591',
'menu_page_so_3216591',
'', // icon default for empty
1 // create before Dashboard menu item
);
}
function menu_page_so_3216591()
{
wp_enqueue_style(
'select-it',
'http://cdnjs.cloudflare.com/ajax/libs/jquery.selectboxit/3.7.0/jquery.selectBoxIt.css'
);
wp_enqueue_style(
'jquery-ui',
'http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.2/themes/base/jquery-ui.css'
);
# Will be used as dependency bellow
wp_register_script(
'select-it',
'http://cdnjs.cloudflare.com/ajax/libs/jquery.selectboxit/3.7.0/jquery.selectBoxIt.min.js'
);
# Main script and dependencies
wp_enqueue_script(
'do-it',
plugins_url( '/js/', __FILE__ ) . 'do-it.js',
array( 'jquery', 'jquery-ui-widget', 'select-it' ) // Dependencies: using bundled WordPress scripts (highly recommended)
);
?>
<div id="icon-post" class="icon32"></div>
<h2>Testing Select Box It</h2>
<p><?php wp_dropdown_categories( array( 'id'=>'select-it-dd' ) ); ?></p>
<?php
}
jQuery(document).ready(function($)
{
$("#select-it-dd").selectBoxIt(
{
theme: "jqueryui"
});
});
你能发布一些源代码或给我们一个页面链接吗?你能试着验证你的HTML标记吗?有时无效的HTML会导致各种奇怪的行为,最好在一开始就排除它。您可以在此处进行验证:
jQuery(document).ready(function($)
{
$("#select-it-dd").selectBoxIt(
{
theme: "jqueryui"
});
});