我正在尝试选择 .singleAnswer 但它不起作用。
查询:
$(".answerContainer").on("click", ".editAnswer", function(e){
e.preventDefault();
answer = $(this).parent('.answerBar').closest('.singleAnswer'); //this variable doenst work
HTML:
<div class='answerContainer'>
<p name='singleAnswer' class='singleAnswer'>$answer[$f]</p>
<input type='hidden' value='$answerid[$f]' class='answer_id' />
<p class='ratingBox'> $answerrating[$f]</p>
<div class='answerBar'>
<a href='#' class='upVote vote'>Upvote</a> · <a href='#' class='downVote vote'>Downvote</a> ·
<a class='answerTime'> $difference $periods[$j] ago</a>
· <a href='#' style='color: orange;' class='editAnswer'><b>Edit</b></a></div>