0

Here are the codes (Jsfiddle demo) :

<a href="#">Click me!</a>

<script>
var a = document.body.children[0]

a.onclick = function() {
  alert('in onlick')
  this.setAttribute('href', 'lala')
  alert('out onclick')
  return false
}

function onpropchange() {
  alert('onpropchange')
}

if (a.addEventListener) { // FF, Opera
  a.addEventListener('DOMAttrModified', onpropchange, false)
}
if (a.attachEvent) { // IE 
  a.attachEvent('onpropertychange', onpropchange)
} 
</script>

When the <a href>Click me!</a> is clicked. The alert('onpropchange') is not executed.. (I'm using Chrome 43.0) Does anyone have any ideas about this?

1

1 Answer 1

2

From the docs of mutation events

This feature has been removed from the Web. Though some browsers may still support it, it is in the process of being dropped. Do not use it in old or new projects. Pages or Web apps using it may break at any time.

Use mutationObserver instead if possible.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.