Changer la couleur de l'arrière plan (background-color) avec jQuery
Voici comment modifier la couleur d'arrière-plan d'une page web ou d'un élément en utilisant jQuery :
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>JS Bin</title> <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> </head> <body> <div style="width:100px; height:100px;"></div> </body> </html>
Dans un tout autre contexte, cet article est très intéressant : afficher les formules à la place des valeurs dans les cellules excel.
$(function($){
	$('body').css('background-color', 'red');
	$('div').css('background-color', 'yellow');
});	Encore faim ? allez lire ça : affiche de western !




 
		
$(document).ready(function(){ (function(){ var i = 0; setInterval(function(){ $("body").removeClass("bg1, bg2, bg3, bg4").addClass("bg"+(i++%4 + 1)); }, 10000); })(); });le voila :
.bg1 { background: red ;} .bg2 { background: blue ;} .bg3 { background: fuchsia ;} .bg4 { background: yellow ;}Il marche aussi bien pour un texte.. Par exemple pour une balise <h1> tu doit remplacer le$("body")par$("h1")