在 IE 中工作,在 Firefox 中,这两个字段是空白的,name 在分配后在 EditUserRoles 中未定义:
GetRows 从 gridview 调用,调用 editUserRoles
<asp:TemplateField HeaderText="Action">
<ItemTemplate>
<input type="button" id="btnEditUserRoles" style="width:60px;" onclick="GetRows(this.parentNode.parentNode.rowIndex)" value="Edit" />
</ItemTemplate>
</asp:TemplateField>
<input type="text" disabled="disabled" id="txtAkoUserName" />
<input type="text" id="txtUserName" />
function GetRows(index) {
var userGrid = document.getElementById('<%=gridUserRoles.ClientID%>');
EditUserRoles(index, userGrid);
}
function EditUserRoles(rowIndex, userGrid) {
if (null != userGrid) {
var userName = userGrid.rows[rowIndex].cells[0].innerText;
var name = userGrid.rows[rowIndex].cells[1].innerText;
LoadEditForm(userName, name);
}
function LoadEditForm(userName, name) {
$("#txtAkoUserName").val(userName);
$("#txtUserName").val(name);
}
最佳答案
Firefox does not support innerText
.只需使用 jQuery 来避免这些跨浏览器问题(这就是它的用途):
var userName = $(userGrid.rows[rowIndex].cells[0]).text();
var name = $(userGrid.rows[rowIndex].cells[1]).text();
关于javascript - Firefox 不喜欢 jquery 中的 .val?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10955477/