treehouse : what would you like to learn today?
Web Design Web Development iOS Development

css id and onClick

  • 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

  • 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.