日期:2014-05-16 浏览次数:20375 次
<table id="table" style="text-align:center;">
<tr>
<td>xxxxxxx</td>
<td> xx xx xx<img src="xxx" id="img_1" onclick="clickAction()"/><div id="div_1" style="display:none;">xxxx<div></td>
<td>xxxxxxx</td>
<td>xxxxxxx</td>
</tr>
<tr>
<td>xxxxxxx</td>
<td> xx xx xx<img src="xxx" id="img_2" onclick="clickAction()"/><div id="div_2" style="display:none;">xxxx<div></td>
<td>xxxxxxx</td>
<td>xxxxxxx</td>
</tr>
</table>
function clickAction(obj){
if(obj.nextSibling.nodeType==1){
obj.nextSibling.style.display = 'block';
return;
}
clickAction(obj.nextSibling);
}
function clickAction(node){
var nodeLeftWidth = node && node.offsetLeft;
alert(nodeLeftWidth);
}
<table id="table" style="text-align:center;">
<tr>
<td>xxxxxxx</td>
<td> xx xx xx<img src="xxx" id="img_1" onclick="clickAction(this)"/><div id="div_1" style="display:none;">xxxx<div></td>
<td>xxxxxxx</td>
<td>xxxxxxx</td>
</tr>
<tr>
<td>xxxxxxx</td>
<td> xx xx xxxxxxxxxxxxxxxxxx<img src="xxx" id="img_2" onclick="clickAction(this)"/><div id="div_2" style="display:none;">xxxx<div></td>
<td>xxxxxxx</td>
<td>xxxxxxx</td>
</tr>
</table>
<script type="text/javascript">
function clickAction(o) {
alert(o.offsetLeft)
}
</script>