/    Sign up×
Community /Pin to ProfileBookmark

Changing style (visibility) with Javascript

Hi,

I’m trying to write a script that allows the viewer to click or hover over a link (a question) that will change the visibility of the following paragraph (the answer) from hidden to visible.

I may have more than one question on each page so I was hoping to pass the ID of the answer to the function (if this would work), so I could view only one answer at a time.

My existing HTML is along the lines of:

<p><a HREF=”#” CLASS=”nowrap”>here is a question<img alt=”question” src=”graphics/why.jpg” CLASS=”questionimage”</a></p>
<p ID=”answer1″ CLASS=”invisible”><b>Answer:</b> the answer is here!</p>

I’m not sure whether it’s easier to use CLASS=”visible” and CLASS=”invisible” rather than specifying the style.

Thanks in advance,

Fraser

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@frasernmauthorJan 09.2003 — Much appreciated,

Fraser
×

Success!

Help @frasernm spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...