「jQuery入門」背景画像を簡単に切り替えるサンプルコード

サンプルコード
(function()
{
var bgCounter = 0,
backgrounds = [
“../../Styles/Changfa_Project1/Images/BACKGROUND_AA_DEMO.png",
“../../Styles/Changfa_Project1/Images/BACKGROUND_BB_DEMO.png",
“../../Styles/Changfa_Project1/Images/BACKGROUND_CC_DEMO.png"
];
function changeBackground()
{
bgCounter = (bgCounter+1) % backgrounds.length;
$('body’).css('background’, '#000 url('+backgrounds[bgCounter]+’) no-repeat’);
setTimeout(changeBackground, 10000);

}
changeBackground();
})();

JavaScript

Posted by arkgame