Call jquery function when
    content change

前端 未结 7 716
遇见更好的自我
遇见更好的自我 2021-01-17 08:40

I try to call jQuery function when ul content is changed.

Below is my code

JS

jQuery(document).ready(function($) {

        $(\'.ProductList\         


        
相关标签:
7条回答
  • 2021-01-17 09:42

    You can use setInterval(funcName, 1800) Check List each 1/2 second if ProductList is changed

    Example jsfiddle

    HTML

    <ul class='ProductList List Clear'>
         <li></li>
         <li></li>
          <li></li>
    </ul>
    

    JS

        function handleProductList(){
            if(jQuery('ul.ProductList > *').size() !=="undefined"){
            var ProductListNum = jQuery('ul.ProductList > *').size();
                console.log(ProductListNum);
            }
        }
    
        /* Check List each 1/2 second */
        setInterval("handleProductList();", 1800);
    
    0 讨论(0)
提交回复
热议问题