2015-09-20 69 views
-2

我收到以下错误给jQuery的语法错误

Uncaught SyntaxError: missing) after argument list 

对于这个jQuery在我的JSP,它使用它获取转换为HTML一些支柱标签,如下图所示:

<script language="JavaScript" type="text/javascript"> 
    $(function(){ 
     var tbl = $("#table");  
     $("#addRowBtn").click(function(){ 
      $('<tr><td><arch:datePicker property="expirationDate" tabindex="${requestScope.tabIndex}" styleId="expirationDate" value="test" imageSrc="/image/content/calendar_icon.gif" alt="date picker" onchange="validateDateFormat(this);" /></td></tr>').appendTo(tbl); }); }); 
</script> 

其解析下面的HTML代码:

<script language="JavaScript" type="text/javascript"> 
    $(function(){ 
     var tbl = $("#table");  
     $("#addRowBtn").click(function(){ 
      $('<tr><td><input id="expirationDate" name="expirationDate" onchange="validateDateFormat(this);" class="sspdatepicker" type="text" alt="date picker State the date in numeric format of MonthMonthDayDayYearYearYearYear. Do not state dashes or slashes. For Example, January 1st 2013 should be stated as 01012013." value="test" maxlength="10"/><a aria-describedby="date" href="#" class="accCalendar datePicker" id="dateIconexpirationDate"><img src="/COMETSHDPortalApp/image/content/calendar_icon.gif" id="expirationDate" alt="date picker" class="sspdatepicker" title="expirationDate Calendar" tabindex="0"/></a><script type="text/javascript"> $A.bind(window, 'load', function(){ $A.setCalendar("UniqueCalendarIdexpirationDate", $A.getEl("dateIconexpirationDate"),$A.getEl("expirationDate"), false, function(ev, dc, targ){targ.value = dc.range[dc.range.current.month].nameShort + '/' + dc.range.current.mDay + '/' + dc.range.current.year;dc.close(); targ.focus();},{className: 'calendar'});});</script></td></tr>').appendTo(tbl); }); }); 
</script> 

提前感谢您的帮助

回答

0

支撑生成的HTML块很好。

你有单引号,第二个双引号问题看起来像。您需要跳过另一个单引号内的单引号:尝试以下版本的解析器:

$(function(){ 
     var tbl = $("#table");  
     $("#addRowBtn").click(function(){ 
      $('<tr><td><input id="expirationDate" name="expirationDate" onchange="validateDateFormat(this);" class="sspdatepicker" type="text" alt="date picker State the date in numeric format of MonthMonthDayDayYearYearYearYear. Do not state dashes or slashes. For Example, January 1st 2013 should be stated as 01012013." value="test" maxlength="10"/><a aria-describedby="date" href="#" class="accCalendar datePicker" id="dateIconexpirationDate"><img src="/COMETSHDPortalApp/image/content/calendar_icon.gif" id="expirationDate" alt="date picker" class="sspdatepicker" title="expirationDate Calendar" tabindex="0"/></a><script type="text/javascript"> $A.bind(window, \'load\', function(){ $A.setCalendar("UniqueCalendarIdexpirationDate", $A.getEl("dateIconexpirationDate"),$A.getEl("expirationDate"), false, function(ev, dc, targ){targ.value = dc.range[dc.range.current.month].nameShort + \'/\' + dc.range.current.mDay + \'/\' + dc.range.current.year;dc.close(); targ.focus();},{className: \'calendar\'});});</script></td></tr>').appendTo(tbl); }); }); 
+0

非常感谢,错误消失了,但日期日历不起作用,当我点击。 – mk1001

+0

请忽略我以前的评论。它没有工作,现在我得到“未捕获的SyntaxError:意外的令牌非法”后尝试您的版本 – mk1001