ユーザーがアイテムをクリックして拡張機能を表示するメガドロップダウンメニューを実行しています。アイテムの onclick で 2 つの結果が必要です。
- 表示される拡張子
- メニュー項目 (クリックされたもの) のために変更する背景色
しかし、私は苦労しており、これらの結果は両方とも onclick イベントが発生する前に発生します。
他のすべてのものはこれまでのところ良好です 以下は私のコードです
//call the showMenu function to toggle menu items display
showMenu("#market", "#marketDrop");
showMenu("#jobs", "#jobsDrop");
showMenu("#career", "#careerDrop");
showMenu("#tech", "#techDrop");
showMenu("#estate", "#estateDrop");
showMenu("#fair", "#fairDrop");
showMenu("#leisure", "#leisureDrop");
showMenu("#exclusive", "#exclusiveDrop");
//the showMenu function
function showMenu(listItem, dropDown){
//first hide the main drop down containers
$(dropDown).hide();
$(listItem).click(function() {
$(dropDown).fadeToggle();
});
$(listItem).click().css("background-color", "#000");
}