Dynamic color change using javascript

can anyone give tips or ideas on how to write a script to select a color on a live page so that the selected color is applicable to the whole .thanks page in advance.

+3
source share
3 answers

Basically, as Darren says, you should change the color bodyusing the jQuery selector. Here you can find a simple user interface such as jQuery ColorPicker .

+1
source

- Javascript, jquery. jQuery, html . , div, :

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

$ DOM ( html, ), css - css.

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>
0
source

Source: https://habr.com/ru/post/1728881/


All Articles