Jquery IE下報錯:缺少識別符號、字串或數字
網上有這種錯誤改正方法,但是都不符合我的規範,
這是網上的說明:
使用Jquery寫特效,firefox、chrome,甚至IE8都能正常執行,不報錯,但偏偏IE7就會報錯:
訊息: 缺少識別符號、字串或數字
相關程式碼如下:
程式碼如下 | 複製程式碼 |
$(".test").css({ |
這是因為.css({})屬性對最後結尾一項zIndex:1後面還帶一逗號“,”結束,刪除這個逗號,正確程式碼如下:
程式碼如下 | 複製程式碼 |
$(".test").css({ |
其它瀏覽器執行一樣正常,關鍵是IE7執行報錯問題也得到了解決,所以寫JQ程式碼時,有必要養成【 .css({})屬性對最後結尾一項後面禁止加逗號“,”結束 】的習慣
但是我的都沒犯這些錯,我的是這樣的,是jQuery的註釋方法問題
這是原來的程式碼:
<table class="easyui-datagrid" id="dgYuanGong" style="width:1000px;height:570px"
data-options="
toolbar:'#tdBiaoTi',
rownumbers:true, <!-- 顯示行數 -->
singleSelect:true,
striped:true, <!-- 交替顯示行背景 -->
scrolling:true,
fit:false,
url:'getYuanGongXinXiAll',
idField:'yuanGongId'
">
<thead>
<tr>
<th data-options="width:80,field:'yuanGongMc',align:'center'">姓名</th>
<th data-options="width:40,field:'xingBie',align:'center'">性別</th>
<th data-options="width:80,field:'buMenMc',align:'center'">部門</th>
<th data-options="width:80,field:'jueSeMc',align:'center'">角色</th>
<th data-options="width:100,field:'yuanGongId',formatter:returnBtnColumn,align:'center'">操作</th>
</tr>
</thead>
</table>
這是改正後的程式碼:
<table class="easyui-datagrid" id="dgYuanGong" style="width:1000px;height:570px"
data-options="
toolbar:'#tdBiaoTi',
rownumbers:true, /* 顯示行數 */
singleSelect:true,
striped:true,/* 交替顯示行背景 */
scrolling:true,
fit:false,
url:'getYuanGongXinXiAll',
idField:'yuanGongId'
">
<thead>
<tr>
<th data-options="width:80,field:'yuanGongMc',align:'center'">姓名</th>
<th data-options="width:40,field:'xingBie',align:'center'">性別</th>
<th data-options="width:80,field:'buMenMc',align:'center'">部門</th>
<th data-options="width:80,field:'jueSeMc',align:'center'">角色</th>
<th data-options="width:100,field:'yuanGongId',formatter:returnBtnColumn,align:'center'">操作</th>
</tr>
</thead>
</table>
改正方法:這是直接在HTML中寫的註釋, <!-- 顯示行數 -->應改為 /* 顯示行數 */