i have following code i want to remove tbl-content
class if recordList
array is empty
<table id="gradient-style">
<tbody class="tbl-content">
<tr>
<%
for (RecordBean record : recordList) {
// some code here to get result
}
%>
<%
if (recordList.isEmpty())
{
%>
<tr>
<td colspan="12" align="center" style="color: red;font-family: verdana">
<h3>No Search records </h3>
</td>
</tr>
<%
}
%>
</tbody>
</table>
here is css
.tbl-content{
height: 650px;;
overflow: auto;
position: absolute;
border: 1px solid gray;
border-top: none;
}
i have following code i want to remove tbl-content
class if recordList
array is empty
<table id="gradient-style">
<tbody class="tbl-content">
<tr>
<%
for (RecordBean record : recordList) {
// some code here to get result
}
%>
<%
if (recordList.isEmpty())
{
%>
<tr>
<td colspan="12" align="center" style="color: red;font-family: verdana">
<h3>No Search records </h3>
</td>
</tr>
<%
}
%>
</tbody>
</table>
here is css
.tbl-content{
height: 650px;;
overflow: auto;
position: absolute;
border: 1px solid gray;
border-top: none;
}
Share
Improve this question
asked Sep 27, 2013 at 11:47
Developer DeskDeveloper Desk
2,3449 gold badges42 silver badges78 bronze badges
4 Answers
Reset to default 5Try this server side inline code
<tbody class="<%= recordList.isEmpty()?"":"tbl-content" %>">
You can write JSTL code directly in script tag.
<script>
<c:if test="${empty recordList}">
//write code here to remove class
</c:if>
</script>
Use Java Expression Language. Its not good practice to use Java Scriptlet. Also you want to be careful not to use JSTL with JavaScript its a mix of concern.
<tbody class=" ${empty recordList ? '' : 'tbl-content' }" >
do it this way:
<table id="gradient-style">
<tbody
<%
if (!recordList.isEmpty())
{
%>
class="tbl-content"
<%
}
%>
>
<tr>
<%
for (RecordBean record : recordList) {
// some code here to get result
}
%>
<%
if (recordList.isEmpty())
{
%>
<tr>
<td colspan="12" align="center" style="color: red;font-family: verdana">
<h3>No Search records </h3>
</td>
</tr>
<%
}
%>
</tbody>
</table>
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744992688a4605000.html
评论列表(0条)