选择父兄弟姐妹的SPECIFIC下一个兄弟

时间:2016-10-11 04:40:01

标签: jquery html css twitter-bootstrap

我是编程和制作一个用户博客应用的新手。博客文章可以有评论。我试图做的只是在点击"评论"之后才显示评论。每个帖子。 我能在这里做到这一点。

$(".comment-area-toggle").click(function(){
$(this).next('.comment-area').slideToggle();

     <li style="margin: none !important;"> Likes: {{ entry.likes }} 
        <a href='/likes/{{entry.id}}/{{entry.likes}}'><span class="glyphicon glyphicon-thumbs-up"></span></a>
        <a href='/dislikes/{{entry.id}}/{{entry.likes}}'><span class="glyphicon glyphicon-thumbs-down"></span></a>
      </li>

      <li class="comment-area-toggle" style="cursor: pointer">Comments:</li> 
      <div class="comment-area">
          <form class="comment-box" action="{{ url_for('add_comment')}}" method="post">
            <dl>
              <li>
                <dd><textarea style="width: 80%; vertical-align: bottom;" name="commenttext" placeholder="Add a comment..." rows="1" cols="40"></textarea>
                <button id="comment" class="btn-comment" type="submit">Comment</button>
              </li>
              <dd><input type="hidden" name="commentid" value = {{entry.id}}>
            </dl>
          </form>
      {% for comment in commentonentries %}
        {% if entry.id == comment.comment_id %}
          <li style="color: rgb(70, 70, 70)">{{ comment.commenttext|safe }}</li>
        {% endif %}
      {% endfor %}        
      </div>

但不是这种方法。

$(".comment-area-toggle").click(function(){
$(this).parent().next('.comment-area').slideToggle();

      <li style="margin: none !important;"> Likes: {{ entry.likes }} 
        <a href='/likes/{{entry.id}}/{{entry.likes}}'><span class="glyphicon glyphicon-thumbs-up"></span></a>
        <a href='/dislikes/{{entry.id}}/{{entry.likes}}'><span class="glyphicon glyphicon-thumbs-down"></span></a>
        <li class="comment-area-toggle" style="cursor: pointer">Comments:</li>
      </li>


      <div class="comment-area">
          <form class="comment-box" action="{{ url_for('add_comment')}}" method="post">
            <dl>
              <li>
                <dd><textarea style="width: 80%; vertical-align: bottom;" name="commenttext" placeholder="Add a comment..." rows="1" cols="40"></textarea>
                <button id="comment" class="btn-comment" type="submit">Comment</button>
              </li>
              <dd><input type="hidden" name="commentid" value = {{entry.id}}>
            </dl>
          </form>
      {% for comment in commentonentries %}
        {% if entry.id == comment.comment_id %}
          <li style="color: rgb(70, 70, 70)">{{ comment.commenttext|safe }}</li>
        {% endif %}
      {% endfor %}        
      </div>

我希望能够使用第二个代码,因为在第一个代码中,问题是我必须放置&#34;注释&#34;在下面的行上喜欢。 我想放置&#34;评论&#34;在喜欢的同一行(我尝试过bootstrap row-col方法,这不是一个很好的解决方案) 现在在第二个代码中,我认为,(this).parent()。next(&#39; .comment-area&#39;)应该选择特定帖子的评论部分,但它不是。 和班级&#34;评论区&#34;有display:none,以便在页面加载时不显示

0 个答案:

没有答案