我有一個場景,我需要顯示一個按鈕,onclick將展開並顯示其餘的值。值來自查詢。例如,如果值大於8,那麼該按鈕需要顯示。我知道這聽起來很簡單,我已經嘗試過類似下面的內容,但有沒有更好的方法來做到這一點?Coldfusion查詢show hide div
<cfif getqry.recordCount neq 0>
<div id="topics" class="posts margin-bottom-40">
<div class="headline"><h2>News </h2>
<cfoutput>
<cfloop query="getqry" startrow="1" endrow="8">
<div class="btn-group hover_drop_down"> <a href="/abc.cfm?newsid=#nid#" class="btn" type="button"> #News_item# </a> </div>
</cfloop>
<cfif getqry.recordCount gt 8>
<div id="collapse-news" class="collapse-inline collapse">
<cfloop query="getqry" startrow="9" endrow="#getqry.recordCount#">
<div class="btn-group hover_drop_down"> <a href="abc.cfm?newsid=#nid#" class="btn btn-news dropdown-toggle" type="button"> #news_item# </a> </div>
</cfloop>
</div>
<button class="btn btn-kw-ml MoreLess" data-toggle="collapse" data-target="##collapse-news">See More</button>
</cfif>
</div>
</cfoutput>
</cfif>
<script type="text/javascript">
$('.MoreLess').click(function(){
var $this = $(this);
$this.toggleClass('MoreLess');
if($this.hasClass('MoreLess')){
$this.text('See More');
} else {
$this.text('See Less');
}
});
</script>