Several "Divs" within a foreach

0

I want an "imdb" star ranking system, but the element only appears once inside 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>
}
    
asked by anonymous 12.05.2016 / 17:12

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>
}
    
12.05.2016 / 17:54