jQuery append is not working on Internet Explorer
I have an issue with the append function. It works on chrome and firefox but not IE.
This is my code:
$('a#ajouterTarification').click(function() {
$("#append_tarification").append($("<div>开发者_Python百科").load("./server/hotels-ajouter-tarifications.php?i="+i).fadeIn(700));
$('#nb_lignes_tarification').val(i);
i++;
});
I think the problem may be caused by .load and .fadeIn in .append. I haven't tested it but try the following:
$('a#ajouterTarification').click(function() {
var $div = $("<div/>"); // First store the new div in a variable
$("#append_tarification").append($div); // Then append
$div.load("./server/hotels-ajouter-tarifications.php?i="+i).fadeIn(700); // Do whatever you want with div
$('#nb_lignes_tarification').val(i);
i++;
});
Try appendTo instead of append. That way, the div gets into your DOM before you start operating on it.
$('a#ajouterTarification').click(function() {
$("<div>").appendTo("#append_tarification").load("./server/hotels-ajouter-tarifications.php?i="+i).fadeIn(700);
$('#nb_lignes_tarification').val(i);
i++;
});
精彩评论