Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/472.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在jquery中获取ul的内容更改事件_Javascript_Jquery_Bind - Fatal编程技术网

Javascript 如何在jquery中获取ul的内容更改事件

Javascript 如何在jquery中获取ul的内容更改事件,javascript,jquery,bind,Javascript,Jquery,Bind,嗨,我有一个ul,这个ul是通过ajax请求填充的。现在我想在内容放置或更改到该ul时触发function。我的ul是这样的 <ul class="prodListing" id="prodListing"></ul> $(".prodListing").bind('contentchange', function() { alert("called"); show_Socialshare();

嗨,我有一个ul,这个ul是通过ajax请求填充的。现在我想在内容放置或更改到该ul时触发function。我的ul是这样的

 <ul class="prodListing" id="prodListing"></ul>
$(".prodListing").bind('contentchange', function() {
                alert("called");
                show_Socialshare();
        });
也试过了

$(".prodListing").change(function(){
            alert("called");
            show_Socialshare();
});

但两者都不起作用。任何人都可以告诉我如何在此事件上启动函数吗?Contentchange不是真正的事件,但如果您知道内容更改的位置,可以将其作为自定义事件触发

 $(".prodListing").trigger("contentchange")

更新:但是,在ajaxrequest的后续操作中处理此问题确实可能是您所需要的。请参阅其他注释Contentchange不是真正的事件,但如果您知道内容更改的位置,可以将其作为自定义事件触发

 $(".prodListing").trigger("contentchange")
更新:但是,在ajaxrequest的后续操作中处理此问题确实可能是您所需要的。请参阅其他注释,您可以使用:

$(document).bind('ajaxComplete', function(){
    alert("called");
    show_Socialshare();
});
这将监视文档中的任何ajax调用,并在完成后运行。

您可以使用:

$(document).bind('ajaxComplete', function(){
    alert("called");
    show_Socialshare();
});

这将监视文档中的任何ajax调用,并在完成后运行。

除了使用DomVariation事件外,没有其他contentchange事件。我建议改为使用填充UL的ajax请求的done或success回调。我建议改为使用填充UL的ajax请求的done或success回调。