2011-07-27 7 views
2

최소한의 문자가 필요한 메시지 시스템이 있습니다. 따라서 기본적으로 사용하지 않는 제출 버튼을 사용합니다. 글자 수 한도가 넘어 오면 제출 버튼을 활성화해야합니다.휴대 기기에서 JQUERY/JAVASCRIPT가 작동하지 않습니다.

내가 사용하는 현재의 코드는 다음과 같습니다 당신이 데스크탑 브라우저 (또한 사파리) 빨간색 제출 버튼의 텍스트 및 한계에 가까워 질 때 색상이 더 녹색에 얻을이 코드

$(window).load(function(){ 
    var amountArray = new Array(85,90,95,120); 
    $('#message').keyup(function(){ 
     var length = $(this).val().length; 
     if(length < amountArray[0]){ 
      $('.verzendenMSG').css('color','red'); 
     }else if(length < amountArray[1]){ 
      $('.verzendenMSG').css('color','darkorange'); 
     }else if(length < amountArray[2]){ 
      $('.verzendenMSG').css('color','olive'); 
      $('.verzendenMSG').removeAttr('disabled'); 
      }else if(length >= amountArray[3]){ 
      $('.verzendenMSG').css('color','green'); 
      $('.verzendenMSG').removeAttr('disabled'); 
     } 
    }); 

정의 된 최소값에 도달하면 제출 버튼의 비활성화 옵션이 사라집니다.

이 모든 기능은 ipad 브라우저 및 Windows phone 7 브라우저와 같은 모바일 브라우저에서 작동하지 않습니다.

제 질문은 무엇이 문제 일 수 있으며 어떻게 문제를 해결할 수 있는지입니다. 이 코드는 실제로 실제로 간단하기 때문에?

+0

시도 단지'$ (...) 불행하게도 작업을 못해' –

+0

에 의해'$ (창) .load (...)를'대체 할 수 있습니다. – Mark

+0

jQuery를 사용하여 iPad 지원에 대한이 기사를 읽을 수 있습니다. 그것은 당신의 문제가되지 않을 수도 있지만 그것은 소리 수도 .... http://exoboy.wordpress.com/2011/05/30/make-your-jquery-website-buttonslinks-work-with-ipadiphone/ – exoboy

답변

0

하면이 같은 $(document)으로 $(window)를 교체하십시오 :

$(document).ready(function(){ 
    var amountArray = new Array(85,90,95,120); 
    $('#message').keyup(function(){ 
     var length = $(this).val().length; 
     if(length < amountArray[0]){ 
      $('.verzendenMSG').css('color','red'); 
     }else if(length < amountArray[1]){ 
      $('.verzendenMSG').css('color','darkorange'); 
     }else if(length < amountArray[2]){ 
      $('.verzendenMSG').css('color','olive'); 
      $('.verzendenMSG').removeAttr('disabled'); 
      }else if(length >= amountArray[3]){ 
      $('.verzendenMSG').css('color','green'); 
      $('.verzendenMSG').removeAttr('disabled'); 
     } 
    }); 
+0

당신은 방금 말한 것일 수 있습니다 - $ (윈도우)를 $ (문서)로 대체하려고합니까? –

+0

죄송하지만 작동하지 않습니다. 보호 된 환경에 있기 때문에 데모를 제공 할 수 없습니다. – Mark

+0

@The_Butcher : 방금 내 대답을 편집했습니다. 보다 나은? – Nathan

관련 문제