Removing onchange event vis the dom

隐身守侯 提交于 2019-12-24 07:26:45

问题


I have the following html

<td valign="top" nowrap="nowrap" align="left" rowspan="4">
<div id="win0divCLASS_SRCH_WRK2_SUBJECT$69$">
<input type="text"
    onchange="addchg_win0(this);oChange_win0=this;"
    maxlength="8"
    style="width:60px; "
    class="PSEDITBOX"
    value=""
    tabindex="31"
    id="CLASS_SRCH_WRK2_SUBJECT$69$"
    name="CLASS_SRCH_WRK2_SUBJECT$69$" />
</div></td>

I'm trying to figure out how to either delete the onchange from the element, or to set it to null..

Articles I've seen indicate that using the removeEventlistener should work. I've tried::

document.getElementById(\"CLASS_SRCH_WRK2_SUBJECT$69$\").removeEventListener('onchange',addchg_win0(this);oChange_win0=this;, false)

as well as

document.getElementById(\"CLASS_SRCH_WRK2_SUBJECT$69$\").onchange=null;

with no luck.

Any pointers/thoughts on this??


回答1:


give a try to document.getElementById("CLASS_SRCH_WRK2_SUBJECT$69$").removeAttribute("onchange");




回答2:


try

document.getElementById("CLASS_SRCH_WRK2_SUBJECT$69$").onchange="";


来源:https://stackoverflow.com/questions/7147355/removing-onchange-event-vis-the-dom

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!