发表时间:2011-11-23
太简单了:
function myAlert(msg, callback, context){ //do something for the msg here alert(msg); //do something end //then callback, for example BUTTON click event if(typeof callback == 'function'){ if(context) callback.call(context); else callback(); } } //------------------------------- //example 1 myAlert('这句是消息', function(){ //这里执行接下来的代码 }); //example 2 var el = $('#my_element'); myAlert('这句是消息2', function(){ this.text('执行完成!'); }, el); |