私はwordpressで働いていました。私はgoogleで見つけました。そして、私を不可解な唯一のものではなく、親リンクはクリック可能持つのサブメニューを展開して許可する親リンクを作成する方法..ですJQuery - 次の親リンクを次のページに移動する代わりに、それ自身のサブリンクを展開する方法を教えてください。
jQuery(document).ready(function() {
//Hide the submenus
jQuery('.leftNav_Level2 ul li ul').hide();
//If its a page parent (based off wordpress), add the class "displayMe"
//This way the accordion will be opened up on the page you are on.
if (jQuery('.leftNav_Level2 ul li').hasClass("current_page_parent")) {
jQuery('.leftNav_Level2 .current_page_parent ul').addClass("displayMe");
jQuery('.leftNav_Level2 .current_page_ancestor > ul').attr('style','display:block');
jQuery('.leftNav_Level2 .current_page_parent > ul').attr('style','display:block');
}
jQuery('.leftNav_Level2 .current_page_item > ul').attr('style','display:block');
//When you click it, toggle
jQuery('.leftNav_Level2 ul li a').click(
function() {
//Onclick Remove the class dipslay me which is only display:block;
//This way they can close it if they click it or it will glitch
jQuery(this).next().next().slideToggle('slow').removeClass("displayMe");
//return false so the # doenst move view to the top of the page
if (jQuery(this).attr('href') == '#') { return false; }
//Close it all out
});
});
ワードプレスのテンプレートがあります。
<div class="leftNav_Level2">
<ul>
<?php wp_list_pages('title_li='); ?>
</ul>
</div><!--/leftNav_Level1-->
意志感謝していただきありがとうございますu
'attrの( 'スタイル'、 '表示:ブロック')' ????それはうまくいくかもしれませんが、地獄のように醜いです。あなたはそれのために 'css()'を使うべきです... – elclanrs
私は本当にあなたが望むものを得ることはできませんが、私はあなたがcssで最も効果的にできると思います。 – janw