How to add class to tr in table using foreach in laravel

Created at 19-Apr-2021 , By samar

How to add class to tr in table using foreach in laravel

Hello everyone, in this post we will look at how to solve "How to add class to tr in table using foreach in laravel" in programming.

  • Add class to tr in table with even and odd number

    --PATH resources\views\<yourfile>.blade.php
    //Add class to odd tr
    <tr class="@if($loop->odd) bg-danger @endif">
    
    // Add class to even tr
    <tr class="@if($loop->even) bg-danger @endif">
    

    You can add class to tr in the table using foreach in laravel using this code snippet. This code snippet basically helps you to add class to every tr on the basis of even and odd order.

Back to code snippet queries related laravel

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Buy Me A Coffee

Don't forget to share this article! Help us spread the word by clicking the share button below.

We appreciate your support and are committed to providing you valuable and informative content.

We are thankful for your never ending support.