次のシナリオでjQueryを学習しようとしています。このために、私は複数のSOの質問を読んだ後、次のjQueryを試しました。しかし、それは機能しませんでした
$(this).closest('.viewLogText').parent().find('.reportLog').css("display", "none");
シナリオ:
Cssクラス「repeaterRecord」を持つdivには3つの子div要素があります。子divには、cssクラス(repeaterIdentifier、viewLogTitle、およびreportLog)があります。
この構造を持つ2つのdivがあります(Cssクラス「repeaterRecord」を持つdiv)。
viewLogクラスのdivは次のようになります。
<div class="viewLogTitle">
<div class="viewLogText">
View Report Log
</div>
<div>
<img alt="Expand" src="Images/PlusIcon.GIF" class="expandLogIcon" />
<img alt="Collapse" src="Images/MinusIcon.GIF" class="collapseLogIcon" />
</div>
</div>
CollapseLogIcon画像をクリックすると、「reportLog」クラス(「viewLogTitle」と同じレベル)で最も近いdivを非表示にする必要があります(のみ)。jQueryを使用してそれを行うにはどうすればよいですか?
更新された作業例:
http://jsfiddle.net/Lijo/L9w4F/11/および http://jsfiddle.net/Lijo/L9w4F/8/および http://jsfiddle.net/Lijo/L9w4F/12/
参照: