lundi 19 janvier 2015

Why does I need setTimeout in this code


$(document).on('click', '#JS_btn1', function(e) {
var self = $(this);
setTimeout(function(){
self.parent('div').html('<a href="javascript:void(0);" class="btn_ok" id="JS_btn2">OK</a>');
});
})


The code shows that #JS_btn1 was replaced by #JS_btn2 before finishing the listener events. Now the question is that why does I need setTimeout in IE7/8 to prevent error?


Aucun commentaire:

Enregistrer un commentaire