私はジャバスクリプトを学んでいます。テキストの一部のブロックを非表示/表示するための単純なオブジェクトを作成してみたいので、このコードを書きました。
var Post = {
init: function(el){
this.el = el;
this.title = el.children(".title");
this.entry = el.children(".entry");
var that = this;
this.title.on("click", function(){
that.hide();
});
},
hide: function(){
this.entry.slideUp('fast');
},
show: function(){
this.entry.slideDown('fast');
}
}
$(".post").each(function(){
Post.init($(this));
})
問題は、このコードは、クリックしたタイトルに関係なく、常に最後の投稿のみを非表示にしていることです。誰が問題がどこにあるのか教えてもらえますか?