Caroline Olivia
Caroline Olivia

Reputation: 356

Jquery toggle individual item in repeater

Hope this question is understandable.

I have a repeater with several rows from the database, and each row has a picture and a button

like this:

 <asp:Repeater runat="server" DataSourceID="SqlDataSource1" ID="repeater1">
                <ItemTemplate>

                    <div class="col-lg-2 col-md-2 col-sm-4 col-xs-6" style="height: 200px;">
                         <div class="thumbnail text-center sletbox">
                            <img class="img-responsive" src='../fotos/<%# Eval("url") %>' alt=""></a>

                             <div class="slet">
                            <a href='delete_picture.aspx?id=<%# Eval("pic_id") %>&a=<%# Eval("album") %>&n=<%# Eval("url") %>' onclick="return confirm('Vil du slette dette billed?')">
                                <h3 class="btn btn-danger btn-xs" id="contact">Slet</h3>
                            </a>
                      </div>

                    </div>

                    </div>
                    <!-- col-lg-4 -->
                </ItemTemplate>
            </asp:Repeater>

Then i have made a jquery function that makes the the button appear by hover, and that works fine.

<script>
    $(document).ready(function () {
        $(".slet").hide();
        $(".sletbox").hover(function () {
            $(".slet").fadeToggle(50);
        });
    });
</script>

But the problem is that it makes ALL the buttons appear, not just the one you're hovering.

So how do i make only the one you're hovering appear?

Upvotes: 2

Views: 312

Answers (1)

vijayP
vijayP

Reputation: 11502

Try with below code:

 $(document).ready(function () {
      $(".slet").hide();
      $(".sletbox").hover(function () {
         $(this).find(".slet").fadeToggle(50); //locating the associated .slet and not the all one.
      });
 });

Upvotes: 2

Related Questions