hidden_element
class の要素をクリックすると ID の非表示の要素を表示し、IDの要素をクリックするshow_hidden_element
と ID の要素を閉じhidden_element
ますclose_hidden_element
。スクリプトを 1 つだけ作成すると、スクリプトは正常に動作しますが、同じ CLASS の要素が 3 つあり、 ID、うまくいきません、誰か助けてください。
これは私のスクリプトです
<article class="post show_hidden_element">
<div id="hidden_element">
<div class="read_box">
<div class="read_box_content">
<h2 class="title">Lorem Ipsum</h2>
<a id="close_hidden_element" class="button_close">×</a>
</div>
</div>
</div>
<div class="border"></div>
</article>
<article class="post show_hidden_element">
<div id="hidden_element">
<div class="read_box">
<div class="read_box_content">
<h2 class="title">Lorem Ipsum</h2>
<a id="close_hidden_element" class="button_close">×</a>
</div>
</div>
</div>
<div class="border"></div>
</article>
<article class="post show_hidden_element">
<div id="hidden_element">
<div class="read_box">
<div class="read_box_content">
<h2 class="title">Lorem Ipsum</h2>
<a id="close_hidden_element" class="button_close">×</a>
</div>
</div>
</div>
<div class="border"></div>
</article>
私のjQueryスクリプトは
$(this).find(".show_hidden_element").click( function(){
$(this).find("#hidden_element").show();
});
$(this).find("#close_hidden_element").click( function(){
$(this).find("#hidden_element").hide();
});