Best way to dynamically change background color of a span or div?

B

Boonish

I have a page with a series of questions as links on the left, and
paragraphs of answers in a column to the right. What I'd like to have
happen is when the user clicks on a question to the left, the answer to
the right changes it's background color slightly to draw attention.

What's the easiest way of going about this? TIA.
 
D

dorayme

Boonish said:
I have a page with a series of questions as links on the left, and
paragraphs of answers in a column to the right. What I'd like to have
happen is when the user clicks on a question to the left, the answer to
the right changes it's background color slightly to draw attention.

What's the easiest way of going about this? TIA.

One simple way, perhaps there are not too many questions?, is to
make each question link to another almost identical page except
one that has the answer to the right with a background that is
different to the 'previous'. Easy to do. Know what I mean?

Perhaps what you want is a hover effect though, because if the
answers are there staring at people to the right of each
question, why will they think it worth it to click? How to get
such a hover effect on the answer's and not the question's
background? Javascript perhaps, fancy this route?
 
R

richard

Boonish said:
I have a page with a series of questions as links on the left, and
paragraphs of answers in a column to the right. What I'd like to have
happen is when the user clicks on a question to the left, the answer to the
right changes it's background color slightly to draw attention.

What's the easiest way of going about this? TIA.

iframe? Place each response in a seperate page with changing backgrounds.
 
J

Jukka K. Korpela

Scripsit Boonish:
I have a page with a series of questions as links on the left, and
paragraphs of answers in a column to the right.

Why? For short questions and fairly short answers, such a tabular
presentation could work well. But then you wouldn't be asking, would you?
What I'd like to have
happen is when the user clicks on a question to the left, the answer
to the right changes it's background color slightly to draw attention.

Why? The questions don't need to be links, since the answer is right there,
on the right of the question.

There's something here that you are not telling us. Like the URL.
 
B

Ben C

I have a page with a series of questions as links on the left, and
paragraphs of answers in a column to the right. What I'd like to have
happen is when the user clicks on a question to the left, the answer to
the right changes it's background color slightly to draw attention.

What's the easiest way of going about this? TIA.

You can use the :active pseudo

e.g.:

..question:active .answer
{
background-color: yellow;
}

<div class="question">
What's the difference between a duck?
<div class="answer">
One of its legs is both the same
</div>
</div>

You could use <dl>, <dt>, <dd> etc for the questions and answers, and
style them appropriately.

This might mean changing how your content's organized a bit. If the
answers are highly dissociated from the questions in the document
structure, it might be easier to use JS and "onclick" events.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top