php - Adding a class to the last listed item -


i list latest 5 events on 1 section of website. , every time item listed, has divider @ bottom. want add last last <li> divider disappear on last item.

so changed <li class="clearfix"> <li class="clearfix last">. how can it?

fyi, <?php $icounterli++; ($icounterli==5)? 'last':''; ?> wont work because may have less 5 upcoming events time time.

thanks!

<?php   $get_latest_events = get_latest_events(5);   if(count($get_latest_events) > 0) {     foreach($get_latest_events $eventdata) {       $entity_data = node_load($eventdata->entity_id);       $event_start_date = check_isset_start_date($entity_data,'event_calendar_date','und');       if($event_start_date !='') {         $explode_event_date = explode(" ",$event_start_date);         $explode_event_day = strtotime($explode_event_date[0]);         $explode_event_time = $explode_event_date[1];         $event_start_day1 = strftime("%b",$explode_event_day);         $event_start_day2 = strftime("%d",$explode_event_day);       }       $location = check_isset($entity_data,'field_location','und');     ?>     <li class="clearfix"></li> 

you don't need class that; can select last element in css doing like:

ul li:last-child


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -