js 根据td节点获取tr节点,及其他td节点的内容,兼容IE、FF、Chrome
html:
<tr class="bg_light" >
<td style="height:30px" align="center" class="lockX">TTTTTT</td>
<td align="center" class="lockX">
TTTTTTTTTTTTTTTTT
</td>
<td style="text-align:left" class="lockX"> TTTTTTTT </td>
<td style="text-align:left" class="lockX"> TTTTTTTTTT </td>
<td style="text-align:left" class="unlock"> TTTTTTTTTTT </td>
<td style="text-align:left" class="unlock"> TTTTTTTT </td>
<td align="center" class="unlock">TTTTTTTTT </td>
<td align="center" class="unlock">TTTTTTT </td>
<td align="center" class="unlock">TTTTTTTT</td>
<td align="center" class="unlock"><%=AVO.getRemark()%> </td>
<td align="center" class="unlock">
<a onmouseover="javascript:showTargetSys(this)">查看</a>
</td>
<td align="center" class="unlock">
TTT
</td>
</tr>
javascript:
function showTargetSys(obj) {
var trNodes = obj.parentNode.parentNode;
var tdNodes = trNodes.childNodes;
var tdNodesArray = new Array();
for(var i = 0; i < tdNodes.length; i++) {
var node = "";
//IE下tagName能识别
//FF、Chrome下tagName不能识别
if(document.all) { //IE
node = tdNodes[i].tagName;
} else { //非IE
node = tdNodes[i].nodeName;
}
if(node.toUpperCase() == "TD") {
tdNodesArray.push(tdNodes[i]);
}
}
var serviceMark = "";
var methodMark = "";
//IE下innerText能识别
//FF、Chrome下innerText不能识别
if(document.all) {
serviceMark = tdNodesArray[4].innerText;
methodMark = tdNodesArray[5].innerText;
} else {
serviceMark = tdNodesArray[4].textContent;
methodMark = tdNodesArray[5].innerText;
}
var random = Math.random();//随机数,只传参,后台不用接收
var url = "<%=contextPath%>/servlet/AjaxServlet?flag=getTargetSys&serviceid="+serviceId+"&methodid="+methodId+"&random"+random;
$.get(
url,
function(response) {
/*$('#targetSys').html(response);*/
alert("response: " + response);
});
/*$('#targetSys').css('display', 'block');*/
}