我在网页上使用了一个jquery表添加行插件,它在Chrome和IE9上的本地桌面上运行正常。
但是当我将项目上传到服务器时,它在Chrome上仍能正常工作,但在IE9上没有任何反应,(有一个addrow按钮,当我点击它时,没有添加任何行)。
你知道为什么会这样吗?我使用最新的jquery版本。
编辑:
<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>
错误是“SCRIPT1028:预期的标识符,字符串或数字xxxxx.aspx,第257行第21个字符”,我已经标记了第257行,它只是一个近距离
答案 0 :(得分:0)
删除changeMonth
$("#<%=ExpiryDate1.ClientID%>").datepicker({
yearRange: '1950:2015',
changeYear: true,
changeMonth: true // Right here
});
“预期的标识符,字符串或数字”表示它收到的内容与预期不同。在这种情况下,因为你有一个逗号,它预计在changeMonth
之后会出现更多的东西,而是你关闭它。
有些浏览器在拼写错误和这样的小错误上往往非常宽容,但IE更严格。这可能是一件好事(强制执行正确的代码),但这也意味着您将遇到更多错误。
答案 1 :(得分:0)
这个“问题”并不是jQuery特有的。 IE不喜欢对象声明中的尾随逗号,而其他浏览器会忽略它。
我建议您通过JSLint运行代码来捕获这样的错误。您可能会获得比IE9更好的错误消息。你会有更清洁的代码!