Hello There, Guest! or RegisterHelp Calendar Member List Search
Displaying a hidden text using Javascript function


Share This Thread:
in
Solved
[How To?] Displaying a hidden text using Javascript function
Hey guys, [justify]I need a Javascript code to make a hidden text visible when a specific button is been clicked.[/justify] [justify]It looks soo simple but I've tried it it's not working, seems I was getting something wrong [/justify]
To display hidden text using JavaScript, you can utilize the "[bold]style[/bold]" property to modify the "[bold]display[/bold]" attribute of the HTML element. Here's a simple example:[br][br] Let's say you have an HTML element like this: [html]<p id="hiddenText" style="display: none;">This text is hidden.</p>[/html][br][br] You can create a JavaScript function to show this hidden text: [html]<script> function showHiddenText() { var hiddenTextElement = document.getElementById("hiddenText"); if (hiddenTextElement.style.display === "none") { hiddenTextElement.style.display = "block"; // Change "block" to "inline" or "inline-block" if needed } } </script> [/html][br][br] Then, you can trigger this function using an event, for example, a button click: [html]<button onclick="showHiddenText()">Show Hidden Text</button>[/html][br][br] This way, when the button is clicked, the JavaScript function will change the display property of the element with the "hiddenText" id, making it visible.[br]Adjust the HTML and JavaScript according to your specific requirements and structure.
wow thanks it just worked :smiling:


Forum Jump:

Users browsing this thread: