我想在点击特定链接时在onclick事件上打开一行。对于我有行数,其中每行下面有一个隐藏行,当我点击行下面的行时,将显示。
CODE:
<script>
function toggle(number) {
alert("toggle function called"+number);
var simNum = number;
if (document.getElementById(simNum).style.display = 'none') {
document.getElementById(${dList.simNumber}).style.display = '';
} else {
document.getElementById(${dList.simNumber}).style.display = 'none';
}
}
</script>
<tr>
<td></td>
<td>${dList.deviceAccount}</td>
<td>${dList.vehicleId}</td>
<td><a href="#" onclick="toggle(${dList.simNumber});">${dList.simNumber}</a></td>
<td>${dList.imeiNumber}</td>
<td>${dList.lastTimestamp}</td>
<td>${dList.lastLoginTime}</td>
</tr>
<tr id="${dList.simNumber}" style="display: none;">
<td align="center" colspan="7">
Expiration Time:<input id="read" type="text" value="${dList.expirationTime}"/>
<input type="button" value="Edit"><input type="button" value="Save">
</td>
</tr>
答案 0 :(得分:0)
更改您的JavaScript代码
function toggle(number) {
alert("toggle function called"+number);
var simNum = number;
if (document.getElementById(simNum).style.display = 'none') {
document.getElementById(simNum).style.display = '';
} else {
document.getElementById(simNum).style.display = 'none';
}
}