2012-06-10 6 views
1
.button { 
     background: transparent url("/assets/LoD-Button-Normal.png") no-repeat bottom right; 
     width: 110px; 
     height: 30px; 
     display: block; 
     background-position: bottom right; 
     text-align:center; 
    } 

    .button_click { 
     background: transparent url("/assets/LoD-Button-Click.png") no-repeat bottom right; 
     width: 110px; 
     height: 30px; 
     display: block; 
     background-position: bottom right; 
    } 

    $(".button").click(function(){ 
     $(this).removeClass("button").addClass("button_click"); 
    }) 

    <a class="button" href="/link"> Button </a> 

버튼을 클릭하면됩니다. 그것은 파이어 폭스에 배경 이미지를 변경하지만 크롬에서 작동하지 않습니다. 제발 도와주세요크롬에서 배경 이미지가 작동하지 않습니다.

+0

작품 :

이 시도 http://jsfiddle.net/3JpLy/을. Chrome의 콘솔에 오류 로그가 있습니까? (F12를 눌러 앞에 가져옴) –

+0

http://jsfiddle.net/QAUaz/ 잘 작동하는 것 같습니다 ... – floorish

+0

어떻게됩니까? 클래스 자체의 변경이 작동하고 배경 이미지가 표시되지 않습니까 (잘못된 URL?) 클래스의 변경이 작동하지 않습니까? – Chris

답변

2

코드가 잘못되어 크롬이 bg 이미지를 변경하기 전에 리디렉션 될 수 있습니다. 이 예에서

$(".button").click(function(e){ 
    e.preventDefault(); 
    $(this).removeClass("button").addClass("button_click"); 
    location.href = $(this).attr('href'); 
    // if for some reason this isn't working you can call setTimeout with the location.href 
}); 
+0

잘 작동합니다. 고마워요. – khanh

관련 문제