投稿前に正直に検索しようとしましたが、特定のものが見つかりませんでした。 私の仕事は、ユーザーがリンクをクリックしたときにブログに隠されたコンテンツを表示することです。 HTMLは次のようになります。私は次のことをやっているが、働いていない今次の子供以外の要素を取得する方法
<div class="entry">
<p>Here is a visible content <a class="a-toggle"> Read More...</a></p>
<div class="hidden_post"><p>Here is all the hidden content</p></div>
</div>
のjQuery:
$(".hidden_post").hide();
$(".a-toggle).click(function() {
$(this).next(".hidden_post").slideDown("slow"); });
をだから私は、最初の親要素に移動する必要がある次の要素を取得するにはそこから検索を進めてください。 これは、私が実際にいくつかの隠された の内容を1つの「エントリ」に持つことになるので、より複雑になります。このように:
<div class="entry">
<p>Here is a visible content <a class="a-toggle"> Read More...</a></p>
<div class="hidden_post"><p>Here is hidden content #1</p></div>
<p>Here is a visible content <a class="a-toggle"> Read More...</a></p>
<div class="hidden_post"><p>Here is hidden content #2</p></div>
<p>Here is a visible content <a class="a-toggle"> Read More...</a></p>
<div class="hidden_post"><p>Here is hidden content #3</p></div>
</div>
私は$(this).parent().next(".hidden_post").slideDown("slow");
を使用する場合、今では「エントリ」のdivに上がるだろうし、その後、最初の「hidden_post」を見つけるでしょう。私は <a class="a-toggle">
から<div class="hidden_post">
のすぐ隣にある別の解決策が必要だと思います。解決策はありますか?
ヤンコク・ヤコブ、いくつかの問題がありますが、私は以下の答えで説明しました。 – Samuel