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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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