jquery html() callback function

后端 未结 4 925
遥遥无期
遥遥无期 2020-11-30 04:48

This question has been asked a couple times but not answered in such a way that it can help me with my specific issue. From a nav list, on click of an item, I\'m loading som

相关标签:
4条回答
  • 2020-11-30 05:10

    In order to check whether image loaded or not you can use following;

    <img src="your_image_path" />
    
    
    <script>
        $('img').load(function() {
            //call_your_function();
        });
    </script>
    
    0 讨论(0)
  • 2020-11-30 05:12
    $('#divId').html(someText).promise().done(function(){
        //your callback logic / code here
    });
    
    0 讨论(0)
  • 2020-11-30 05:26
    $(window).load(function() {
      // code here
    })();
    
    0 讨论(0)
  • 2020-11-30 05:31

    Based on Mike Robinson's (and dystroy's) suggestion the answer to my question is:

    $("#myContentDiv").html('HTML content comes here');
    var contentImages = $("#myContentDiv img");
        var totalImages = contentImages.length;
        var loadedImages = 0;
        contentImages.each(function(){
            $(this).on('load', function(){
                loadedImages++;
                if(loadedImages == totalImages)
                {
                    $("#myContentDiv").tinyscrollbar();
                }
            });
        });
    
    0 讨论(0)
提交回复
热议问题