0

ワードプレスで子テーマを作成しました。サブメニューの表示と非表示に jQuery を使用しています。IE を除くすべてのブラウザーですべてがうまく機能します。IE では、私の jQuery はどれもサブメニューに対して機能しません。デバッグしようとすると、このエラーが発生します。

行: 3 エラー: 構文エラー、認識できない式: nth-of-type

そのエラーは、wordpress が使用する組み込みの jQuery ライブラリに表示されます。私は自分の Jquery で nth-of-type セレクターを使用していますが、それらを削除しても問題は解決しません。これは、サブメニューを制御するために使用しているjQueryです

if ($("body").hasClass('taxonomy-colordesign')){
$("#hybrid-categories-5 h4").toggleClass("tabDown");//pulls the background image in the tab
$("#hybrid-categories-5 h4").siblings('.dots').toggleClass('active');//activates the little square next to it
$("#hybrid-categories-5 h4").next("ul.xoxo.categories").toggleClass("openTab");//opens up the ul that contains the list of options
$(".menu-main-menu-container li:nth-of-type(3) a").addClass("current");
} 

else if ($("body").hasClass('taxonomy-colorart')){
$("#hybrid-categories-12 h4").toggleClass("tabDown");
$("#hybrid-categories-12 h4").siblings('.dots').toggleClass('active');
$("#hybrid-categories-12 h4").next("ul.xoxo.categories").toggleClass("openTab");
$(" #hybrid-categories-9, #hybrid-categories-3, #hybrid-categories-5").hide();
$(".menu-main-menu-container li:nth-of-type(2) a").addClass("current");

}

else if ($("body").hasClass('taxonomy-mediadesign')){
$("#hybrid-categories-3 h4").toggleClass("tabDown");
$("#hybrid-categories-3 h4").siblings('.dots').toggleClass('active');
$("#hybrid-categories-3 h4").next("ul.xoxo.categories").toggleClass("openTab");
$(".menu-main-menu-container li:nth-of-type(3) a").addClass("current");

}

誰かが私を助けることができれば、本当に感謝しています。

4

1 に答える 1

2

cosnth-of-typeは有効なjqueryセレクターではありません。

例えば。

$(".menu-main-menu-container li:nth-of-type(2) a").addClass("current");無効ですに変更します

 $(".menu-main-menu-container li:eq(2) a").addClass("current");

ドキュメントについては、 http ://api.jquery.com/nth-child-selector/またはhttp://api.jquery.com/eq/を参照できます。

于 2012-04-15T17:42:51.473 に答える