2012-05-15 8 views
-1

내 웹 페이지에 jquery table add row plugin을 사용하고 Chrome 및 IE9의 로컬 데스크톱에서 정상적으로 작동합니다.IE9에서 Jquery가 작동하지 않습니다.

그러나 프로젝트를 서버에 업로드 할 때 여전히 Chrome에서 제대로 작동하지만 IE9에서는 아무런 변화가 없습니다 (추가 버튼이 있는데 클릭하면 행이 추가되지 않음).

이유가 궁금하십니까?

최신 jquery 버전을 사용합니다.

편집 :

오류가 "SCRIPT1028 : 식별자 문자열이나 숫자 xxxxx.aspx, 라인 257 문자 (21) 예상이"

<table id="tblotherlicence" style="width:800px" cellspacing="2" cellpadding="3">  
     <tr><td class="formtitle" colspan="5">OTHER PROFESSIONAL LICENSURE<a style="font-size:7pt">(e.g.,registered psychiatric nurse; registered massage therapist; registered social worker)</a></td></tr> 
     <tr><td class="formlabel">Profession</td> 
      <td class="formlabel">Licence Number</td> 
      <td class="formlabel">Jurisdiction</td> 
      <td class="formlabel">Date of Expiry</td> 
      <td class="formlabel"><input class="addrow" type="button" value="Add Row" /></td></tr> 
     <tr> 
      <td><asp:TextBox ID="Licence1" runat="server"></asp:TextBox> 
      </td> 
      <td><asp:TextBox ID="LicenceNumber1" runat="server"></asp:TextBox> 
      </td> 
      <td><asp:TextBox ID="Jurisdiction1" runat="server"></asp:TextBox> 
      </td> 
      <td><asp:TextBox ID="ExpiryDate1" runat="server"></asp:TextBox></td> 
      <td><input class="delrow" type="button" value="Delete Row" /></td> 
     </tr> 
    </table> 

<script type="text/javascript"> 
      $(document).ready(function() { 
       $("#<%=ExpiryDate1.ClientID%>").datepicker({ 
         yearRange: '1950:2015', 
         changeYear: true, 
         changeMonth: true, 
     257  }); 
       $(".addrow").btnAddRow(function() { 
        var i; 
        var rowCount = $("#tblotherlicence tr").length; 
        for (i = 3; i <= rowCount; i++) { 
         $("#tblotherlicence tr:nth-child(" + i + ") td:nth-child(4) input[type='text']").attr("id", "MainPlaceHolder_RecordofNursing1_ExpiryDate" + (i - 2));    
         $("#tblotherlicence tr:nth-child(" + i + ") td:nth-child(4) input[type='text']").removeAttr("class"); 
         $("#tblotherlicence tr:nth-child(" + i + ") td:nth-child(4) input[type='text']").datepicker({ 
           yearRange: '1950:2015', 
           changeYear: true, 
           changeMonth: true, 
         }); 
        } 
       }); 
       $(".delrow").btnDelRow(); 
      }); 
    </script> 
, 난 그냥 가까운 브래킷

+9

안녕하세요, Pita. 질문 할 때 항상 코드를 보여주십시오. –

+1

코드 또는 일부 코드 샘플의 jsFiddle을 게시하십시오. 어쩌면 일어나는 페이지의 URL일까요? –

+0

어떤 종류의 서버입니까? 브라우저에서 js 오류 메시지를 확인하십시오. 또한 작동하지 않는 기능이 ie9에서 지원되는지 확인하십시오. –

답변

0
입니다 라인 257을 표시 한

은 후 후행 쉼표를 제거 changeMonth

$("#<%=ExpiryDate1.ClientID%>").datepicker({ 
    yearRange: '1950:2015', 
    changeYear: true, 
    changeMonth: true // Right here 
}); 

가 돼있 것을 다른 무언가를받는 것을 의미한다 "식별자 문자열이나 숫자는 예상". 이 경우 쉼표가 붙어 있으므로 changeMonth 뒤에 오는 물건이 더 많을 것으로 예상하지만 대신 닫습니다.

일부 브라우저는 오타 및 약간의 오류에 매우 관대하는 경향이 있지만 IE는 더 엄격합니다. 이는 좋은 코드 일 수 있지만 오류가 더 많이 발생 함을 의미합니다.

+0

그것이 문제입니다! 정말 고맙습니다!!! – pita

0

이 "문제"는 jQuery에만 해당되는 것이 아닙니다. IE는 객체 선언에서 후행 쉼표를 싫어하지만 다른 브라우저는이를 무시합니다.

JSLint을 통해 코드를 실행하여 이와 같은 오류를 catch하는 것이 좋습니다. IE9에서 얻은 것보다 훨씬 좋은 오류 메시지가 나타날 것입니다. 그리고 훨씬 더 깨끗한 코드를 갖게 될 것입니다!

관련 문제