折りたたみ可能なタブとトグル+/-ボタンを備えたアコーディオンNAVセットアップがあります。
'タブ'DIVをクリック可能にしようとしています。コードの一部に次の関数を追加し、repedititive toggle()関数を削除しましたが、それでも正しく機能していません-
更新しました
$('.tabs').click(function() {
}
)
私のHTML
<div id="tab1" class="tabs">NEWS [<a href="#" class="button" id="plus1">more</a>]</div>
<div class="expandable" id="one">
<p>This is placeholder text.</p></div>
<div id="tab2" class="tabs">EVENTS [<a href="#" class="button" id="plus2">more</a>]</div>
<div class="expandable" id="two">
<p>This is placeholder text.</p></div>
そして私のJavaScript
$(window).load(function(){
$(document).ready(function(){
$(".expandable").hide();
$(".button").show();
$('.tabs').click(function() { // added new
$('.button').toggle(function(){
$(".expandable").slideDown(
function(){
$(".button").text("less")
}
);
},function(){
$(".expandable").slideUp(
function(){
$(".button").text("more")
}
);
});
}); // end of click
});
});
もともとはタブごとにtoggle()関数を使って設定していましたが、そうしないように言われました。私はJS構文に苦労しているので、この時点でどこに行けばいいのかわかりません。
人々に感謝します。