【发布时间】:2013-01-17 17:41:21
【问题描述】:
CSS:
<style>
body{font-family: arial; }
.nopad{padding-bottom:5px;}
.exBt:before {content: "[+]";float:left;padding-right:3px;}
.exBt_nobtn {height:12px;width:12px;float:left;padding-left:50px;}
</style>
JQuery:
<script>
jQuery(document).ready(function(){
jQuery(".nopad").each(function(){
if (jQuery(this).find('div').hasClass('.exBt'))
{
jQuery(this).find(".taskName").css('font-weight','bold');
jQuery(this).find(".taskName").css('font-size','16px');
}
});//end each
});//end main
</script>
HTML:
<div class="nopad">
<div class="exBt"></div>
<div class="taskName">This is a title</div>
</div>
<div class="nopad">
<div class="exBt_nobtn"></div>
<div class="taskName">this is subcontent</div>
</div>
<div class="nopad">
<div class="exBt_nobtn"></div>
<div class="taskName">this is subcontent</div>
</div>
此代码运行良好。我只是想让它来处理这个:
<div class="nopad${addDivClass}">
<c:choose>//tests if heading content has child content
<c:when test="${item.nestHead}">
//if it has content use one class(add a-+ icon)
<div class="extBt" id="extBt-${item.itemId}"></div>
</c:when>
<c:otherwise>
//if there is no child content loaded by ajax just indent with another class
<div class="extBt_nobtn" id="extBt-${item.itemId}"></div>
</c:otherwise>
</c:choose>
我对 JSTL Core 很陌生,但我认为那样做会更干净——我只是不知道怎么做
【问题讨论】:
-
我不清楚问题是什么。
-
我正在寻找 jquery 所做的事情,但使用 JSTL 核心代替。只是一个 JSTL 等价物
-
我不明白这个问题——你已经知道什么时候使用每个类了,看起来 JS 所做的只是在
.extBt时添加更多的 CSS。使用与现在相同的逻辑并添加另一个类,或修改extBt类。 -
顺便说一句,您的 HTML 无效。多个元素具有相同的
id是非法的。 -
已更正无效部分,以免影响发布此问题的原因