Well, I have a demo image
When a user clicks on one, the background of the body will change according to what he has chosen. But in this case the background is an image that matches those colors. How can I do this?
Well, I have a demo image
When a user clicks on one, the background of the body will change according to what he has chosen. But in this case the background is an image that matches those colors. How can I do this?
Basis of how you want to adapt Leandro's code:
$("#azul").click(function() {
$("body").css({
"background": "url(azul.png)";
});
$("#cinza").click(function() {
$("body").css({
"background": "url(cinza.png)";
});
$("#vermelho").click(function() {
$("body").css({
"background": "url(vermelho.png)";
});
});
Good with javascript is more difficult ... I will use jquery if you want to use usa!
<div id="azul">azul</div>
<br>
<div id="vermelho">vermelho</div>
<br>
<div id="cinza">cinza</div>
<br>
Well, just read and code is not difficult ... anything is false
$("#azul").click(function() {
$("body").css({
"background": "blue";
});
$("#cinza").click(function() {
$("body").css({
"background": "#ccc";
});
$("#vermelho").click(function() {
$("body").css({
"background": "red";
});
});
EDIT: Leandro, do not forget to put ";" to close. This is important.