私はこのツリーを動的に作成しています。問題は、それらがすべて同じクラス名を持っているため、開いているすべてのdivを閉じることです。
使用しようとしています$(this).parent().next('.sticker').hide();
が、何も起こりません。私はそれを間違って使用していますか?
$('#note-btn').click(function() {
$.get('xml/note.xml', function(data) {
$(data).find('notes').each(function() {
var notes = '<div class="notes">';
notes += '<div class="notes-close">' + '</div>';
$('#page-content-wrapper').append(notes);
});
$(".notes-close").click(function()
{
$(this).parent().next('.notes').toggle();
});
});
});
});
これの出力はです。
<div id="page-content-wrapper">
<div class="notes">
<div class="notes-close"></div>
</div>
</div>
ここで、note-closeは、ノートの閉じるボタンです。