2012-05-10 4 views
0

배경 이미지가 "클릭하면"사라지도록하고 싶습니다. 지금 여기에 있습니다. 그리고JQuery, 클릭시 백그라운드 사진으로 희미 해짐

$(document).ready(function() { 
//this represents window.load in javascript. 

//now to select the element suppose you have anchor tag <a> with id=clickme 

$("#test").click(function() { 

//select the element whose background image you want to change. suppose with id=imgBack 
$("body").css({'background-image':'url(url to image)'}); 


}) 
}); 
+0

0을 가진 페이드보다 100 % 불투명도를가집니다. – Cristy

답변

1

당신은 사업부를 만들고, 거기에 backgrund에-이미지를 가지고, 다음은 디스플레이로 설정되어 있어야합니다 ... 키우면 작동,하지만 난 이미지가 페이드 - 인을 클릭에서 원하는 : 없음;

그런 다음 클릭 기능에 당신은 당신이 당신이 그것을 원한다면 그렇게 (밀리 초) 페이드하는 방법을 빨리 알려주는 번호를 전달할 수 있습니다() 함수 fadeIn이

$('#wrapperdiv').fadeIn(); 

을 400ms 동안 움직이기 위해서는 다음과 같이 작성하십시오. .fadeIn (400);

0

여기에 live example입니다.

HTML :

<body> 
    <div id="no_background"></div> 
    <div id="wrapper"> 
    <!-- page content goes here --> 
    <input type="button" id="test" value="Show background"> 
    </div> 
</body> 

CSS :

body { 
    background: url(/path/to/background.png); 
} 

#no_background { 
    background: white;  
    position: fixed; 
    left: 0px; 
    top: 0px; 
    width: 100%; 
    height: 100%; 
    z-index: 1; 
} 

#wrapper { 
    position: relative; 
    z-index: 2; 
} 

JS : 먼저 (사업부 또는 뭔가)이 위에 또 다른 배경을 추가 할 필요가

$("#test").click(function() { 
    $("#no_background").fadeOut(); 
});