MutationObserver
MDN传送门
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<div class="btn-next disabled" onclick="clickMe()">clickMe</div>
</body>
</html>
点击clickMe删除disabled,代码省略
var targetNode = document.querySelector('.btn-next');
var config = { attributes: true, childList: true, subtree: true };
var callback = function(mutationsList) {
for(var mutation of mutationsList) {
if (mutation.type == 'childList') {
console.log('A child node has been added or removed.');
}
else if (mutation.type == 'attributes') {
console.log('The ' + mutation.attributeName + ' attribute was modified.');
}
}
};
var observer = new MutationObserver(callback);
observer.observe(targetNode, config);
observer.disconnect();