Jump to content

Collapsible Content that Degrades Gracefully


BLaZuRE

Recommended Posts

I'm looking into creating a structure where a paragraph is hidden until the user clicks a line.  I know I could do it using the onLoad method for <body>, but I want it to be an event detected using something on the tag (like using onLoad for the tag itself, which doesn't work, or searching by class) for expandability.

 

Also, the paragraph should be visible to users without JavaScript.

 

I like coding efficiently, so I don't grab all the tags and search by class name, in case there are a lot of the same tag.

 

I hope I made myself clear.

You can place random bits of JavaScript like that at the bottom of your document - just before the closing body tag - without the need for an event. As a plus point, the code will be executed before the page has loaded - so the user isn't likely to see the paragraph disappear at all. On-load events, including the custom 'jQuery document ready' event, both execute after the page has finished loading, which sometimes can be noticeable.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.