2013-12-13 3 views
0

내 이미지 롤오버를 관리하는 jQuery 스크립트가 있습니다. 내 스크립트는 PC에서 제대로 작동하지만 불행히도이 스크립트는 iDevices (iPad, iPhone)와 호환되지 않습니다. iDevice에서 jQuery 스크립트 롤오버가 호환되지 않습니다.

image-normal.jpg <=> image-hover.jpg

은 당신이 나를 도와 주실 수 있습니까?

$(document).ready(function(){ 
    $(function() { 
    $('img.rollover').hover(function() { 
     $(this).css("cursor", "pointer"); 
     this.src = this.src.replace("-normal","-hover"); 
    }, function() { 
     this.src = this.src.replace("-hover","-normal"); 
    }); 
    }); 
}); 
+0

터치 스크린에서 호버를 사용할 수 없습니다. 기간. – Blazemonger

+0

'$ (document) .ready (함수)'와'$ (함수)'는 같은 것이지, 둘 다 사용하는 이유를 모르겠습니다. 참조 : http://api.jquery.com/ready/ – ToastyMallows

+0

JS (및 jQuery)의 초보자입니다. – Xroad

답변

0

이 시도 :

$(document).ready(function(){ 
    $(function() { 
     $('img.rollover').on('mouseenter touchstart', function(){ 
      $(this).css("cursor", "pointer"); 
      this.src = this.src.replace("-normal","-hover"); 
     }); 

     $('img.rollover').on('mouseleave touchend', function(){ 
      this.src = this.src.replace("-hover","-normal"); 
     }); 
    }); 
}); 

당신은 여전히 ​​유혹이 없기 때문에 모바일 이미지를 터치 (클릭)해야합니다.

+0

작동하는 것 같습니다! 고마워요! – Xroad

+0

테스트를 마친 후 문제가 생겼습니다. iDevices에서 버튼을 다시 클릭하면 "정상"상태로 돌아 가지 않습니다. – Xroad