2013-07-26 3 views
0

here의 자바 스크립트 코드는 자동 슬라이드 이미지이지만, .box1 클래스를 클릭하면 onclick 코드로 변환해야합니다.클릭하면 크로스 페이드 배경 이미지

그리고 box1 클래스 크로스 페이드를 클릭하면 id = # main에있는 배경 이미지에만 영향을줍니다. 크로스 페이드는 박스 1에 영향을 주어서는 안되며, 배경 이미지가 사라질 때 연속적으로 나타나야합니다.

크로스 페이드 배경 이미지의 경우 이미지는 이미지 폴더에 직접 연결해야합니다. #main에서 이미지 폴더와 배경 이미지로 연결해야합니다.

어떤 사람의 도움이 될 수 있습니다.

my code is here

var timer = setInterval(nextImage, 4000); 
var curImage = 0; 
var numImages = 5; 

function nextImage() { 
    var e; 
    // remove showMe class from current image 
    e = document.getElementById("slideimg" + curImage); 
    removeClass(e, "showMe"); 
    // compute next image 
    curImage++; 
    if (curImage > numImages - 1) { 
     curImage = 0; 
    } 

    // add showMe class to next image 
    e = document.getElementById("slideimg" + curImage); 
    addClass(e, "showMe"); 
} 

function addClass(elem, name) { 
    var c = elem.className; 
    if (c) c += " "; // if not blank, add a space separator 
    c += name; 
    elem.className = c; 
} 

function removeClass(elem, name) { 
    var c = elem.className; 
    elem.className = c.replace(name, "").replace(/\s+/g, " ").replace(/^\s+|\s+$/g, ""); // remove name and extra blanks 
} 

답변

관련 문제