擁有這片HTML的:MooTools事件委託:如何引用回調中的子元素?
<div id="modal">
<select class="country">
<option value=""></option>
<option value="opt">Opt</option>
</select>
</div>
這一塊的JS:
$('modal').addEvent('change:relay(.country)', function(){
console.log(this); // "this" refers to #modal.
}).fireEvent('change:relay(.country)');
日誌顯示,this
關鍵字指#modal元素。我想爲每個.country選擇一個事件並在回調中引用每個。我怎麼能擁有它? 這是小提琴:http://jsfiddle.net/EWUCG/5/ 非常感謝!
我有同樣的問題。這是要走的路,即使這個線程可能已經死了... http://stackoverflow.com/questions/2689010/mootools-programmatically-fired-events-not-working-with-event-delegation?rq=1 – zhealot 2012-09-10 20:58:24