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



我正在创建一个带有API的Web应用程序,并用HTML编写了某种帮助页面。 为了清楚起见,我想在单击按钮时隐藏并显示一些文本。

我已经得到了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>

但是我不知道ho 编写 help(( 函数,它使按钮工作。我正在ASP.NET 核心中编写应用程序。 我知道有很多例子,但我发现的那些似乎都不适合我的问题。 知道怎么做吗?这就是现在的样子。该按钮不起作用。

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>

最新更新