jsp中实现分层的几种常用方法

1、list展示,通常展示为隔行变色,<tr>标签表示html中的一行

设置背景,在tr标签中 style="background:${status.count%2==0?'gray':'white' }" 

status.count 实现遍历的次数

<tbody>
    		<c:forEach items="${list }" var="info" varStatus="status">
	    		<tr style="background:${status.count%2==0?'gray':'white'}">
	    			<td>${info.bookCode }</td>
	    			<td>${info.bookType }</td>
	    			<td>${info.bookName }</td>
	    			<td>${info.createdBy }</td>
	    			<td>${info.publishPress }</td>
	    			<td colspan="2">
	    			<c:if test="${info.isBorrow == 0}">
   					<a href="" >申请借阅</a>
					</c:if>
					<c:if test="${info.isBorrow == 1}">
    				<a style="1px soild red">已借阅</a>
					</c:if>
	    			</td>
	    		</tr>
    		</c:forEach>
    		</tbody>

2、通过jQuery 实现每一行都变色(特殊情况某一行不执行,可以单独选择出这一行)

$(function() {		
	$("tr:even").css("background", "blue");
	$("tr:odd").css("background", "green");
	$("tr:last").css("background","null");
});

效果图:

猜你喜欢

转载自blog.csdn.net/qq_41902618/article/details/81118822
今日推荐