js实现点击某个按钮展示或者隐藏tr一行的数据
2017-07-31 15:47
543 查看
页面样式如下:
<tbody>
<c:forEach items="${dataList}" var="dat" varStatus="index">
<tr id="tr_${index.count}" openShow="0">
<td >${(pageNo-1)*pageSize+index.count} </td>
<td title="${dat['AW_NAME'] }">${dat['AW_NAME'] }
<c:choose>
<c:when test="${my431fn:getRedisChildListSizeById(dat['AW_ID']) > 0}">
<c:set var="childSize" scope="request" value="${my431fn:getRedisChildListSizeById(dat['AW_ID']).toString()}"/>
<c:set var="childList" scope="request" value="${my431fn:getRedisChildListById(dat['AW_ID'])}"/>
<a id="open_${index.count}" onclick="openChildList('${index.count}')">展开</a>
</c:when>
<c:otherwise>
<c:set var="childSize" scope="request" value="-"/>
</c:otherwise>
</c:choose>
</td>
<td title="${dat['WORKSPACE_CODE'] }">${dat['AW_CODE'] }</td>
<!-- <td>-</td> -->
<td>${childSize}</td>
<td>${my431fn:getRedisUserById(dat['MOD_USER']).realname}</td>
<td>${dat['MOD_TIME'] }</td>
<td>
<a class="green" href="###" onclick="del('${dat['AW_ID'] }')">删除</a> |
<a class="green" href="###" onclick="create('${dat['AW_ID'] }')">修改</a> |
<a class="green" href="###" onclick="createChild('${dat['AW_ID'] }','${dat['AW_NAME'] }','${dat['AW_CODE']}')">添加子工程</a> |
<a class="green" href="###" onclick="orderChild('${dat['AW_ID'] }','${dat['AW_NAME'] }','${dat['AW_CODE']}')">子工程排序</a> |
<a class="green" href="${root}/base/BaseAreaWorkSpace/initData.jspx?myId=${dat['AW_ID']}" target="_blank">初始化数据</a> |
</td>
</tr>
<c:if test="${childSize != '-' && childSize > 0}">
<c:forEach items="${childList}" var="cList" varStatus="index2">
<tr id="tr_${index.count}_${index2.count}" style="display:none;" >
<td style="text-align:right">${index2.count})</td>
<td>${cList.awName}</td>
<td>${cList.awCode}</td>
<td>-</td>
<td>${my431fn:getRedisUserById(cList.modUser).realname}</td>
<td>${my431fn:formaterDate(cList.modTime)}</td>
<td><a class="green" href="###" onclick="delChild('${cList.id}')">删除</a> |
<a class="green" href="###" onclick="create('${cList.id}')">修改</a> |
</td>
</tr>
</c:forEach>
</c:if>
</c:forEach>
</tbody>
js代码:
//折叠显示子工程
function openChildList(index){
//父工程
var tr = $("#tr_"+index+"");
var status = tr.attr("openShow");
//子工程
var trChild = $("tr[id^='tr_"+index+"_']");
if(status == 0){
tr.attr("openShow",1);
trChild.each(function(){
$(this).show();
$("#open_"+index+"").text("折叠")
})
}else{
tr.attr("openShow",0);
trChild.each(function(){
$(this).hide();
$("#open_"+index+"").text("展开")
})
}
}
<tbody>
<c:forEach items="${dataList}" var="dat" varStatus="index">
<tr id="tr_${index.count}" openShow="0">
<td >${(pageNo-1)*pageSize+index.count} </td>
<td title="${dat['AW_NAME'] }">${dat['AW_NAME'] }
<c:choose>
<c:when test="${my431fn:getRedisChildListSizeById(dat['AW_ID']) > 0}">
<c:set var="childSize" scope="request" value="${my431fn:getRedisChildListSizeById(dat['AW_ID']).toString()}"/>
<c:set var="childList" scope="request" value="${my431fn:getRedisChildListById(dat['AW_ID'])}"/>
<a id="open_${index.count}" onclick="openChildList('${index.count}')">展开</a>
</c:when>
<c:otherwise>
<c:set var="childSize" scope="request" value="-"/>
</c:otherwise>
</c:choose>
</td>
<td title="${dat['WORKSPACE_CODE'] }">${dat['AW_CODE'] }</td>
<!-- <td>-</td> -->
<td>${childSize}</td>
<td>${my431fn:getRedisUserById(dat['MOD_USER']).realname}</td>
<td>${dat['MOD_TIME'] }</td>
<td>
<a class="green" href="###" onclick="del('${dat['AW_ID'] }')">删除</a> |
<a class="green" href="###" onclick="create('${dat['AW_ID'] }')">修改</a> |
<a class="green" href="###" onclick="createChild('${dat['AW_ID'] }','${dat['AW_NAME'] }','${dat['AW_CODE']}')">添加子工程</a> |
<a class="green" href="###" onclick="orderChild('${dat['AW_ID'] }','${dat['AW_NAME'] }','${dat['AW_CODE']}')">子工程排序</a> |
<a class="green" href="${root}/base/BaseAreaWorkSpace/initData.jspx?myId=${dat['AW_ID']}" target="_blank">初始化数据</a> |
</td>
</tr>
<c:if test="${childSize != '-' && childSize > 0}">
<c:forEach items="${childList}" var="cList" varStatus="index2">
<tr id="tr_${index.count}_${index2.count}" style="display:none;" >
<td style="text-align:right">${index2.count})</td>
<td>${cList.awName}</td>
<td>${cList.awCode}</td>
<td>-</td>
<td>${my431fn:getRedisUserById(cList.modUser).realname}</td>
<td>${my431fn:formaterDate(cList.modTime)}</td>
<td><a class="green" href="###" onclick="delChild('${cList.id}')">删除</a> |
<a class="green" href="###" onclick="create('${cList.id}')">修改</a> |
</td>
</tr>
</c:forEach>
</c:if>
</c:forEach>
</tbody>
js代码:
//折叠显示子工程
function openChildList(index){
//父工程
var tr = $("#tr_"+index+"");
var status = tr.attr("openShow");
//子工程
var trChild = $("tr[id^='tr_"+index+"_']");
if(status == 0){
tr.attr("openShow",1);
trChild.each(function(){
$(this).show();
$("#open_"+index+"").text("折叠")
})
}else{
tr.attr("openShow",0);
trChild.each(function(){
$(this).hide();
$("#open_"+index+"").text("展开")
})
}
}
相关文章推荐
- JS实现点击参数面板按钮显示或隐藏数据
- JS实现点击参数面板按钮显示或隐藏数据
- JS实现点击参数面板按钮显示或隐藏数据
- JS实现点击参数面板按钮显示或隐藏数据
- IOS实现点击软键盘的Next/Return按钮或者空白处后自动隐藏键盘
- JSP类似购物车根据后台数据自动生成一行商品,点击按钮实现数量价格自动增加
- jquery 实现点击 table中一行tr自动复制本行添加到本行之后 点击按钮回复到初始状态
- 动态的把数据显示在table中,点击某一行的删除按钮实现该行的删除(通过ajax实现页面的无刷新加载)
- Repeater中添加按钮实现点击按钮获取某一行数据的方法
- 动态的把数据显示在table中,点击某一行的删除按钮实现该行的删除(通过ajax实现页面的无刷新加载)
- 不使用JS,使用CSS3 target 以及 动画效果实现,点击一下弹出,并且保持弹出状态,然后再点击一下弹回的导航栏(或者可以叫做按钮)
- js如何实现点击一个按钮显示一个div,然后该div上有一个按钮,点击此按钮后隐藏,隐藏的同时显示另外一个div,而在次弹出的div也有一个按钮,点击后隐藏.
- js <table>中点击一行中任意列数据,则可以让<checkbox>选中或者取消选中
- 完成用户数据的导出,生成文本文件Users.txt,实现点击按钮自动下载
- js中实现隐藏页面一行
- 动态表格,通过点击按钮增加或者删除一行表格!
- .Net 点击按钮实现动态添加行并保持页面的数据不变
- Repeater控件中点击按钮后获取某一行的数据!
- js 实现点击浏览图片按钮时同时显示图片
- 注册或者点击按钮时,防止用户重复提交数据