タイトルによって切り替わる4つのdivがあります(以下に示すように、1つのセットを示しました)。各タイトルリンククラスは、テキストフィールドクラスの前のクラスと一致します。javasciptを4回別々に作成する代わりに、$ thisを使用して現在のクラスをターゲットにし、次に現在のクラスをクラステキストとして使用して、ドライヤーを作成したいと考えていました。
important_info_headerクラスは、各divの動的クラスになります。
この種の文章ではそれほど素晴らしいものではないので、どんな助けでも大歓迎です
失敗した試み
$(this).click(function() {
$(this+'.text').slideToggle('slow', function() {
//ani complete.
});
});
作業マークアップ
HTMLスタート
<h4><a href="javascript:void(0)" class="important_info_header"><%= t("catalog_items.show_lot.important_info_header")%></a></h4>
<div class="important_info_header text">
<p><%= t("catalog_items.show_lot.important_info") %></p>
</div><!-- /text -->
<h4><a href="javascript:void(0)" class="important_info_header"><%= t("catalog_items.show_lot.important_info_header")%></a></h4>
<div class="important_info_header text">
<p><%= t("catalog_items.show_lot.important_info") %></p>
</div><!-- /text -->
<h4><a href="javascript:void(0)" class="rules"><%= t("catalog_items.show_lot.important_info_header")%></a></h4>
<div class="rules text">
<p><%= t("catalog_items.show_lot.important_info") %></p>
</div><!-- /text -->
<h4><a href="javascript:void(0)" class="shipping"><%= t("catalog_items.show_lot.important_info_header")%></a></h4>
<div class="shipping text">
<p><%= t("catalog_items.show_lot.important_info") %></p>
</div><!-- /text -->
HTML END
$('.important_info_header').click(function() {
$('.important_info_header.text').slideToggle('slow', function() {
//ani complete.
});
});