jquery一次打开一个部分

时间:2016-10-14 15:42:33

标签: javascript php jquery laravel

我目前正致力于laravel 5.2。我正在尝试为每个帖子制作评论部分。这是我的刀片视图, `

<div class="row">
    <section class="col-md-12"> 
        @foreach($storages as $storage)
        @if($storage->post_id==$post->id) 
        <div id="jumbo3" class="jumbotron">
            <div class="row" id="rlr">
                <section class="col-md-offset-1 col-md-2">
                    <img  id="imagesize8" class="img-circle" src="/src/uploads/avatars/{{$storage->user->avatar}}"/>
                </section>
                <section class="col-md-3">
                    <a id="user10" href=""><h5 id="h52">{{$storage->user->getNameOrUsername() }}</h5></a>
                </section>
                <section class="col-md-offset-3 col-md-3">
                    <span id="rmvsgn1" class="glyphicon glyphicon-remove-sign"></span>

                </section>
            </div>
            @if($storage->comment==0)
            <div class="row">
                {{ $storage->textcomment}}
            </div>
            @endif
            @if($storage->textcomment==0)
            <div class="row">
                <img src="{{$storage->comment}}"/>
            </div>
            @endif

            @endif
            @endforeach
    </section>
    </div>
    <button class="see-more">See Comments</button>
    </div>
    </div>
    @endif
    @endforeach

我试图通过点击评论部分来显示评论,这里是我的jquery,

<script>
    $(document).ready(function () {
        $('.jumbotron').hide('.jumbotron');
        $('.see-more').click(function () {
            $('.jumbotron').toggle('.jumbotron');
        });
    });
</script>

但是每当我试图将它放在一个部分时,它就会打开所有帖子。

1 个答案:

答案 0 :(得分:0)

int i, j;

j = 0;
for (i=0;i<N;i++)
  if (good(array[i]) )
    array[j++] = array[i];

N = j;
$(document).ready(function() {
  $(".see-more").click(function(){
  	$(this).prev( ".content" ).toggle();
    
  });
});