Several "Divs" inside a foreach

Asked

Viewed 143 times

0

I want to put a ranking system with stars like "imdb", but the element only appears once within the cycle.

Script:

<script>
    $(document).ready(function () {
        $(function () {
            $("#rateYo").rateYo({

                onChange: function (rating, rateYoInstance) {

                    $(this).next().text(rating);
                }
            });
        });
    });
</script>

Html:

@foreach (var item in ViewBag.catequizandoSessao)
{
    <tr>
        <td>                          
            <div id="rateYo"></div>
            <div class="counter"></div>
        </td>
    </tr>
}

1 answer

1

<script>
    $(document).ready(function () {
        $(function () {
            $(".rak").rateYo({

                onChange: function (rating, rateYoInstance) {

                    $(this).next().text(rating);
                }
            });
        });
    });
</script>

@foreach (var item in ViewBag.catequizandoSessao)
{
    <tr>
        <td>
            <div id="rateYo" class="rak" ></div>
            <div class="counter"></div>
        </td>
    </tr>
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.