如何在 child.js
中覆盖 aFunction
?
我希望子事件监听器可以触发,但不触发 aFunction
,并且我不能修改 parent.js
。
这是否可能?
index.html:
<th class="foo">foo
<span class="bar" data-feather="arrow-down"></span>
</th>
parent.js:
parent = {
init: function() {
parent.aFunction($('.foo'));
},
aFunction: function(element) {
element.on('click', function() {
alert('foo');
});
}, ...
window.onload = parent.init;
child.js:
$('.bar').on('click', function() {
alert('bar');
});