{if $smarty.foreach.new_goods.iteration < 4}class="top"{/if}<!--{foreach from=$index_hot_goods_2 item=goods name=new_goods}--><li {if $smarty.foreach.new_goods.iteration < 4}class="top"{/if}> <span class="item-info"> <span class="item-title"><a href="{$goods.url}">{$goods.short_name|escape:html}</a></span> <span class="item-price"><!-- {if $goods.promote_price neq ""} -->{$goods.promote_price}<!-- {else}-->{$goods.shop_price}<!--{/if}--></span> </span> <span class="item-thumb"> <a href="{$goods.url}"><img src="{$goods.thumb}" alt="{$goods.name|escape:html}" style="width:70px" /></a> </span> <span class="item-num">{$smarty.foreach.new_goods.iteration}</span> </li><!--{/foreach}-->
这段的意思是 第四个 li 样式没有class="top"
{$smarty.foreach.new_goods.iteration}
这段意思是数字递增
如果要换到其他标签里面 请替换 name="" 里面的红色字 或者直接加上name=new_goods