比如有个div,我想往里插入元素的时候能捕获这个插入的动作,以便我有后续的操作。当然我不是指用计时器每一段时间去看这个div有没有元素进来,我要的是能直接捕获这个动作的方法,谢谢大家。

解决方案 »

  1.   


    function startCatch(){
    if(theDiv.childNodes.length == chlidNodeLength){
    setTimeout('startCatch()',50);
    }
    else{
    chlidNodeLength = theDiv.childNodes.length;
    //有删除或添加元素,接下来干我想干的事
    }
    }
    var chlidNodeLength = theDiv.childNodes.length;
    startCatch();我的意思其实就是找类似自定义事件捕获,达到上面代码的行为的脚本,请各位大虾指教,谢谢
      

  2.   


    function startCatch(){
                if(theDiv.childNodes.length == chlidNodeLength){
                    setTimeout('startCatch()',50);
                }
                else{
                    chlidNodeLength = theDiv.childNodes.length;
                    setTimeout('startCatch()',50);
                    //有删除或添加元素,接下来干我想干的事
                }
            }
            var chlidNodeLength = theDiv.childNodes.length;
            startCatch();
    高手们指导下吧。。