BLaZuRE Posted April 15, 2011 Share Posted April 15, 2011 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. Quote Link to comment Share on other sites More sharing options...
sunfighter Posted April 16, 2011 Share Posted April 16, 2011 look into jquery: http://jquery.com/ On the main page click the "RUN CODE" button and see if this is what you want. Quote Link to comment Share on other sites More sharing options...
Adam Posted April 16, 2011 Share Posted April 16, 2011 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.