3

can anyone pls give sugessions or ideas on how to write the script for selecting a color in a live page so that the selected color should apply to whole page.thanks in advance.

2
  • Welcome to StackOverflow, Patel! Commented Jan 18, 2010 at 6:29
  • thank u jonathan sampson... im new to this jQuery.. pls help me out if i ve any doubts... thanks in adavnce Commented Jan 18, 2010 at 6:38

3 Answers 3

1

Basically as darren says you should change your body color with jQuery selector. A simple UI can be found here, for example jQuery ColorPicker.

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

Comments

0

A common way to do this is with a Javascript support framework like jquery. Using jQuery you can select elements in your html and change their attributes. For example if you wanted to set the background color for all your div elements, you would do:

$("div").css("background-color", "blue");

Here the $ function lets you select DOM elements (html elements that are part of your loaded page), and the css function applies some css rule to them.

Comments

0

Online demo: http://jsbin.com/ezeze

document.getElementById("colors").onchange = function(){ 
  document.getElementById("container").style.color = this.value; 
}

--

<select name='colors' id='colors'> 
  <option>red</option> 
  <option>green</option> 
  <option>blue</option> 
</select> 
<div id="container"> 
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p> 
  <p>Curabitur dolor metus, aliquam in convallis ut, pharetra ac enim.</p> 
  <p>Ut lobortis justo in dolor rutrum vulputate.</p> 
</div>

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.