隐藏基于if条件的HTML按钮 [英] Hide a HTML button based on a if-condition

查看:59
本文介绍了隐藏基于if条件的HTML按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个JSP页面,其中包含一个名为下载"的按钮.我想根据if条件隐藏此按钮.

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

下载"按钮用于在单击鼠标时生成并下载PDF.

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

我有一个要从Controller获取的列表,如果该列表为空,我想在JSP页面上隐藏下载"按钮.

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.

这是我的按钮,

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

如果列表为空,我想隐藏按钮.

I want to hide the button if the List is 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");

这篇关于隐藏基于if条件的HTML按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆