jquery – 使onpropertychange和domattrified工作以检测元素何时被更改

前端之家收集整理的这篇文章主要介绍了jquery – 使onpropertychange和domattrified工作以检测元素何时被更改前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
什么东西应该触发,不是吗?
我在IE8中不受支持,在Fx 3.6.10中没有发生任何事情
<html>
<head>
<script src="http://code.jquery.com/jquery-1.4.2.js"></script>
<script>


// modified from http://pragmatec.blogspot.com/2009/06/google-toolbar-style-and-tooltip.html
jQuery(function($){
  $.fn.dommodhandler = function(options){
    function setListeners(){
      if (typeof (this.onpropertychange) == "object"){
        $('#innerDiv').bind('propertychange',function(e){
          $('#msgDiv').html(this.id+' changed</br/>');
        });
      }
      else if ($.browser.mozilla){
      $('#msgDiv').html("bind");
        $('#innerDiv').bind('DOMAttrModified',function(e){
          $('#msgDiv').html(this.id+' changed</br/>');
        });
      }
      else {
        $('#msgDiv').html('not supported in this browser');
        return false;
      }
    }
    return setListeners();
    }
  }
);
$(document).ready(function(){
  $.fn.dommodhandler ();
});

</script>
</head>
<body>
<div id="wrapper">
<a href="#" onClick="document.getElementById('innerDiv').height='300px';document.getElementById('innerDiv').innerHTML=new Date(); return false">Click</a>
  <div id="outerDiv">
    <div id="innerDiv">Hello</div>
  </div>
  <div id="msgDiv"></div>      
</div>  

</body>
</html>

更新:仍然不开心…任何人有任何建议,以检测什么时候(ajax)由于更大或更小的内容而改变div的实际高度

解决方法

如果您实际更改了属性,则事件将触发(FF 3.6.10): http://jsfiddle.net/Nw4rA/
原文链接:https://www.f2er.com/jquery/178323.html

猜你在找的jQuery相关文章