樣品的HTML標記以下的jQuery選擇父問題
<div class="container answer_comments">
<p class="comment_text">Hey that's not cool.</p>
<p class="comment_attribs">By Anonymous User on 01 Dec</p>
<p class="comment_text">Is that really why?</p>
<p class="comment_attribs">By person on 27 Nov</p>
<p class="close_comments" onclick="close_comments()">Close</p>
</div>
JS功能:
function close_comments() {
var comments_wrapper = $(this).closest('.answer_comments');
comments_wrapper.slideUp();
}
.answer_comments不會關閉。是因爲即時通訊使用$(this)錯誤?這個div在頁面上重複了很多次,那麼實現我想要做的最好的方法是什麼?
這樣的作品,非常感謝。 – stef 2009-12-01 20:53:59