简体   繁体   English

在 asp.net 内核中单击按钮时隐藏和显示文本

[英]Hide and show text on button click in asp.net core

I'm creating a web app with an API and wrote some kind of help page with HTML.我正在使用 API 创建一个 web 应用程序,并使用 HTML 编写了某种帮助页面。 For the sake of clarity, I want to hide and show some of the text on button click.为了清楚起见,我想在按钮单击时隐藏和显示一些文本。

I already got the HTML code for that.我已经得到了 HTML 代码。

<li> GET https://someurl.com/api/getallInformation - some text about data</li>
<div>
    <button onclick="help()">Show Text</button>
</div>
<div id="Text">
    <li>Text that should be shown and hidden on Button click </li>
</div>

But I do not know ho to write the help()-function , that makes the button work.但是我不知道如何编写使按钮起作用的help()-function I'm writing the app in ASP.NET Core .我正在ASP.NET Core中编写应用程序。 I know there are many examples, but none of those I found seem to fit my problem.我知道有很多例子,但我发现的这些例子似乎都不适合我的问题。 Any idea how to do it?知道怎么做吗? Thats what it looks like now.这就是它现在的样子。 The button just does not work.按钮只是不起作用。

 function help() { var x = document.getElementById("Text"); if (x.style.display === "none") { x.style.display = "block"; } else { x.style.display = "none"; } }
 <button onclick="help()">Help</button> <div id="Text"> <li>Text that should be shown and hidden on Button click </li> </div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM