我的代码如下:
<a onmouseup="some operation" class="buttonBarButtonContainer" title="">
<div name="buttonBarButton_Save" id="manualDeductionSaveButtonDisable" class="buttonBarButton">
<table style="height:20px;" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td nowrap="true">
<button class="noTransformButton ico_tb-save"></button>
</td>
</tr>
</tbody>
</table>
</div>
这里我只有div id,我想禁用父锚标记。我能怎么做?我只能使用javascript,甚至不能使用jquery?
答案 0 :(得分:2)
根据以下代码使用parentElement.removeAttribute(&#39; onmouseup&#39;)。请务必将javascript放在页面的底部处(我更改了#34;某些操作&#34;到警报,以便您可以注释掉javascript以验证它是否会禁用锚点警报未注释的):
<a onmouseup="alert('hi');" class="buttonBarButtonContainer" title="">
<div name="buttonBarButton_Save" id="manualDeductionSaveButtonDisable" class="buttonBarButton">
<table style="height:20px;" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td nowrap="true">
<button class="noTransformButton ico_tb-save">Test</button>
</td>
</tr>
</tbody>
</table>
</div>
</a>
<script type="text/javascript">
document.getElementById("manualDeductionSaveButtonDisable").parentElement.removeAttribute('onmouseup');
</script>
&#13;