<ul>
我需要检查$(document).on('click', '.selector', function(event){
var id = $(this).data('id');
event.stopPropagation();
var $target = $(event.target);
$.ajax({
type: "GET",
url: "components/display.cfc?method=displayFields&ID=" + id + "&returnformat=plain",
success: function(html){
$('.myDiv').append(html);
if ( $target.closest("td").attr("colspan") > 1 ) {
$target.slideUp();
} else {
$target.closest("tr").next().find("p").slideToggle();
}
},
error: function(jqXHR,textStatus,errorThrown){
console.log(textStatus);
}
});
});
何时向下滑动,以便我可以重置/删除html的值。这怎么可能?
答案 0 :(得分:2)
幻灯片切换能够执行幻灯片动画后发生的函数回调。这可能适用于您的情况。
幻灯片切换的文档可在此处阅读:http://api.jquery.com/slidetoggle/
适合您的情况:
$(someElement).slideToggle(function(){
//Any code in here will be executed after the slideToggle function has finished
});
答案 1 :(得分:1)
在callback
功能后放置slideToggle()
;
$(document).on('click', '.selector', function(event){
var id = $(this).data('id');
event.stopPropagation();
var $target = $(event.target);
$.ajax({
type: "GET",
url: "components/display.cfc?method=displayFields&ID=" + id + "&returnformat=plain",
success: function(html){
$('.myDiv').append(html);
if ( $target.closest("td").attr("colspan") > 1 ) {
$target.slideUp();
} else {
$target.closest("tr").next().find("p").slideToggle();
alert("Finished"); // <- callback here
}
},
error: function(jqXHR,textStatus,errorThrown){
console.log(textStatus);
}
});
});