我在jsp中有動態填充的表。 我對所有表格行都使用了相同的id。IE10:getElementsByName()沒有返回在IE10中具有相同Id的元素
在JavaScript中我想檢索所有表格行元素的id爲「resultRow」。 和getElementsByName(「resultRow」)在JS給出IE10
空的HTMLCollection是否有任何其他的方式來獲得匹配的ID
任何幫助是極大的讚賞
'這是我的代碼片段的tablerows
In JSP:
<table id="subSecondTable" cellpadding="0" cellspacing="0">
<c:set var="loopCount" value="0" />
<c:forEach var="vinList" items="${requestScope.vehicleDetailsPO}">
<tr id="resultRow" height="10" class="handCursor"
onclick="rowColorChange('<c:out value="${loopCount}"/>','<c:out value="${vinList.vin}"/>');">
In js:
function rowColorChange(rowNumber,vin){
var rows=document.getElementsByName("resultRow");
var columns;
rowHighlighted=rowNumber;
for(i=0;i<rows.length;i++){
if (i==rowNumber){
rows[rowNumber].style.backgroundColor="blue";
//change the text color for the highlighted row
columns = rows[rowNumber].cells
for(j=0;j<columns.length;j++){
columns[j].style.color = "white";
}
//change the text color for the highlighted row
var previousRowint = parseInt(previousRow);
if (previousRow != rowNumber)
{
columns = rows[previousRowint].cells
for(j=0;j<columns.length;j++){
columns[j].style.color = "black";
}
}
previousRow=rowNumber;
if(vin==''){
vin = rows[parseInt(rowHighlighted)].cells[3].innerText;
}
document.getElementById("txtCopyVin").value=vin;
document.getElementById("txtCopyVin").select();
}else{
rows[i].style.backgroundColor="white";
}
}
if(window.event!=null){
rows[rowNumber].cells(window.event.srcElement.cellIndex).focus();
}
}`
你檢查什麼是IE10產生的HTML來取代ID =「resultRow」? – Satya 2013-05-01 17:02:31
變量行是IE10中的空集合 生成的Html與Ie9中的相同 – Harish 2013-05-01 17:20:46