0

我在更改类后对某些元素进行了单击操作,我需要检测到这一刻并做一些事情。对于我使用的 IE 以外的其他浏览器MutationObserve,但 IE 不支持此功能,所以我使用OnPropChanged但有些不对劲,谁能告诉我什么?

element.click(function(){
   function OnPropChanged (event) {
       if (event.propertyName.toLowerCase () == "class") {
           alert ("The new content: " + event.srcElement.value);
       }
   }
   observe_target.attachEvent ("onpropertychange", OnPropChanged);
)};

非常感谢您的帮助。

4

1 回答 1

0

The property name is "className", not "class" (although the attribute's name is "class"). Also, if you really want to attach the event on click, make sure the element is only clickable once, or you'll get multiple event handlers observing the same property.

于 2013-06-19T14:50:51.870 回答