2

i want to write a script for changing of text color and image color on click .. here i want to call the external style sheets (which i ll be creating) to the function .. each color ll be ve ng differnt .css page. so that when i click the orange color the text and the image background should change to to the orange color if i click to red it should change to red..can anyone pls help me out in dis.. any ideas or sugessions... thanks in advance.

1
  • Your English is hard to interpret. I gave up after reading 3 times. Please write normal sentences with full words and if necessary run a spellchecker. Good luck. Commented Jan 19, 2010 at 12:08

1 Answer 1

3

Define each colour as a class in your CSS:

.red {
color: red;
}

.blue {
color: blue;
}

Then set a click attribute in your HTML:

<p onclick="javascript: this.setAttribute('class', 'red');">Click to make me red</p>
<p onclick="javascript: this.setAttribute('class', 'blue');">Click to make me blue</p>

There are optimisations not described here - using unobtrusive javascript mainly - but this should give you a start.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.