0

这是我的html代码:

<div id="cmdt_1_29d" class="dt_state2" onclick="sel_test(this.id)">
    <img id="cmdt_1_29i" onclick="dropit('cmdt_1_29');"
         src="http://hitechpackaging.zes.zeald.com/interchange-5/en_US/ico_minus.png">
    <span class="dt_link">
        <a href="javascript://">CARTON &amp; BOARD</a>
    </span> 
</div> 
<div id="cmdt_2_31d" class="dt_istate1" onclick="sel_test(this.id)">
    <img src="/site/hitechpackaging/images/items/test.jpb ">
    <a href="https://secure.zeald.com/hitechpackaging/shop/CARTON%20%20%20%20BOARD/CORRUGATED%20%20CORNER%20BOARD?mv_pc=21497">CORRUGATED &amp; CORNER BOARD</a>
</div>

dropit 函数修改了我不想修改的 img src,不幸的是我无法修改,我可以在修改数据之前以某种方式将数据读入数组,并且可以将数据添加回图像。

4

1 回答 1

0

要删除点击处理程序:

var i = document.getElementById('cmd1_1_29i');
i.onclick = null;

或者,如果您仍想调用原始点击处理程序:

var i = document.getElementById('cmd1_1_29i');
_onclick = i.onclick;

i.onclick = function(e) {
    // do what you want here
    _onclick && _onclick.apply(this, [e]);
}
​
于 2012-05-24T04:17:21.157 回答