MehPanzer
MehPanzer

Reputation: 19

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. 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.

<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. I'm writing the app in 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.

Upvotes: 0

Views: 2414

Answers (1)

Sezer T&#252;rkdal
Sezer T&#252;rkdal

Reputation: 193

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>

Upvotes: 1

Related Questions