Grow your CSS skills. Land your dream job.

css id and onClick

  • # November 16, 2012 at 10:53 am

    Hi

    I have a row of 4 blocks, set up with php all have same id called “Option”, and have a onClick function.
    When you click it the number shows up which one you clicked… but only the first one ever changes
    colour?

    here is the link http://www.fgraphics.co.uk/test/test1.php – do a view source to see code.

    so, any help on how I make the actual ‘block’ you click change colour and not just the first one all the time….

    I know this can be done if I have id=”option1″ id=”option2″ etc… but I am trying to avoid this and have just
    one id, but somehow change the colour of the one that is selected.

    thanks so much for reading!

    rogueIkon

    # November 16, 2012 at 11:13 am

    ID’s are only to be used once…which is where you are probably going wrong.

    Try creating a class that will do the same thing and then add that using JS.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".