Hide a HTML button based on a if-condition

拈花ヽ惹草 提交于 2021-01-29 05:34:24

问题


I have a JSP page which includes a button called "Download".I want to hide this button based on a if-condition.

The Download button is meant to generate and download PDF onclick of it.

I have a List that is being fetched from the Controller and if this list is empty, I want to hide the "Download" button on the JSP page.

This is my button,

<button type="button" class="btn bg-red waves-effect" onclick="ExportPdf()">Download</button>  

I want to hide the button if the List is empty.


回答1:


Display when list isn't empty:

<% if (!list.isEmpty()){ %>
<button type="button" class="btn bg-red waves-effect" onclick="ExportPdf()">Download</button>  
<% } %>

For example if you fetch list from attribute

ArrayList<String> list = (ArrayList<String>) request.getAttribute("listName");


来源:https://stackoverflow.com/questions/56236527/hide-a-html-button-based-on-a-if-condition

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!