Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Show and hide text

Featured Replies

Hi

 

I was wondering, without the use of javascript, if it's possible to have a link which shows and hides a block of text below it on click. This would also have to push the content below it down when opening.

 

Thanks if you can help

Yeah, thats possible.

 

Add onClick attribute in the tag that holds the text.

For example:

<span onClick="appear()">This is some text. !</span>

 

Now add a javascript function that makes an element visible.

<script type="text/javascript">
function appear()
{
document.getElementById("IdOfElement").display="block";
}
</script>

 

If you click the text, javascript makes the element with an Id of "IdOfElement" visible.

( Of course you first have to make the element unvisible by adding display:none; in your css )

 

Let me know if it worked ;)

@Leonvv He said without javascript ;)

 

Without refreshing the page? Not that I know of. There might be a way to do it with HTML5 but I'm not aware of it if there is.

 

If you allow for page refreshing you could do it with PHP IF statements. Button click refreshes the page and adds GET variable, the elements are then inside IF statements that display or not depending on what the GET variable is. Bit clunky though, what is stopping you from using Javascript?

Edited by Glowbridge

Here's a tutorial for the PHP If and Get that Glowbridge decribed.

http://www.wickham43.net/showform.php#phpnewsbox

You can just see that the News Box does expand when you click the Football link - it blocks another line of text on its left as it increases in height so the box is in effect expanding as more content is displayed inside it.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.