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

Discussion in 'HTML' started by Boonish, Sep 30, 2006.

  1. Boonish

    Boonish Guest

    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.
    Boonish, Sep 30, 2006
    #1
    1. Advertising

  2. Boonish

    dorayme Guest

    In article <2006092916283116807-boog@felchcom>,
    Boonish <> wrote:

    > 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?

    --
    dorayme
    dorayme, Sep 30, 2006
    #2
    1. Advertising

  3. Boonish

    richard Guest

    "Boonish" <> wrote in message
    news:2006092916283116807-boog@felchcom...
    >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.
    richard, Sep 30, 2006
    #3
  4. 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.

    --
    Jukka K. Korpela ("Yucca")
    http://www.cs.tut.fi/~jkorpela/
    Jukka K. Korpela, Sep 30, 2006
    #4
  5. Boonish

    Ben C Guest

    On 2006-09-29, Boonish <> wrote:
    > 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.
    Ben C, Sep 30, 2006
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Fulio Open

    Can span include span?

    Fulio Open, Jun 26, 2009, in forum: HTML
    Replies:
    5
    Views:
    536
    dorayme
    Jun 26, 2009
  2. Stéphane Klein
    Replies:
    2
    Views:
    1,738
    John Nagle
    Mar 30, 2010
  3. Rob
    Replies:
    3
    Views:
    155
  4. mscir
    Replies:
    3
    Views:
    298
    Martin Honnen
    Jun 26, 2005
  5. James Black
    Replies:
    2
    Views:
    109
Loading...

Share This Page