現在、wp_list_pagesを選択したメニューに移動するjQuery関数があります。これは、ページを選択するときに選択したページにナビゲートします。私は 'current_page_item'クラスを使うことができますか?&これを変換して現在のページを 'selected'オプションに設定しますか?私の現在のコードは以下の通りです:現在のページクラスを「選択された」メニューに変換する
$('li.current_page_item').attr('selected', 'selected');
alert($('ul.selectdropdown')[0].selectedIndex);
$(function() {
$('ul.selectdropdown').each(function() {
var $select = $('<select />');
$(this).find('a').each(function() {
var $option = $('<option />');
$option.attr('value', $(this).attr('href')).html($(this).html());
$select.append($option);
$select.change(function() { window.open($select.find(':selected').val(), '_top'); });
});
$(this).replaceWith($select);
});
});
は、コードが動作していないですか?そうでない場合、何が機能していないのですか? JsFiddle.netのデモへのリンクを教えてください。 –