I am wondering if it is possible for once a user clicks on a button on a html/jsp website that something appears on the same page? So essentially some text is hidden until the button is click and then it will appear? I'm new to web dev so am unsure if this is even possible, thanks
可以将文章内容翻译成中文,广告屏蔽插件会导致该功能失效:
问题:
回答1:
Use JavaScript to toggle the display
style attribute of an element:
const display = () => document.querySelector('#elt').style.display = 'block';
const hide = () => document.querySelector('#elt').style.display = 'none';
<button onclick="display()">Display</button>
<button onclick="hide()">Hide</button>
<div id="elt">Hello world</div>
回答2:
You can use Jquery to dynamically show and hide elements on your page. I would recommend looking at it
https://jsfiddle.net/rxnfwzoj/1/
here is a small example of the .hide()
and .show()
function