<tr> <td onclick="[TR].setAttribute('class','newName')">My TD</td> </tr>@H_502_3@ 我该怎么做?
我该怎么做?
现在..在你的情况下,你需要td的parentNode属性..
<tr> <td onclick="this.parentNode.setAttribute('class','newName')">My TD</td> </tr>@H_502_3@ 或者像他在评论中建议的那样 <td onclick="this.parentNode.className= 'newName'">My TD</td>@H_502_3@
或者像他在评论中建议的那样
<td onclick="this.parentNode.className= 'newName'">My TD</td>@H_502_3@